about summary refs log tree commit diff
path: root/nix/templates/goapp/backend/main.go
diff options
context:
space:
mode:
authorEmile <git@emile.space>2025-02-19 19:53:25 +0100
committerEmile <git@emile.space>2025-02-19 19:53:25 +0100
commitae39f02812bcfe903e956220c890bfb7b9bb9ff4 (patch)
treedff7028627665a7d2cb7cd64533ac74ec8919379 /nix/templates/goapp/backend/main.go
parent07425c679f7399284c0fe3dcbee54f45b23d07a0 (diff)
removed the backend, added the frontend with oidc support
So I've added oidc support which is nice, yet I have to test this
with some https foo, so I'm pushing this.
Diffstat (limited to 'nix/templates/goapp/backend/main.go')
-rw-r--r--nix/templates/goapp/backend/main.go80
1 files changed, 0 insertions, 80 deletions
diff --git a/nix/templates/goapp/backend/main.go b/nix/templates/goapp/backend/main.go
deleted file mode 100644
index d793869..0000000
--- a/nix/templates/goapp/backend/main.go
+++ /dev/null
@@ -1,80 +0,0 @@
-package main
-
-import (
-	"flag"
-	"fmt"
-	"log"
-	"net/http"
-	"os"
-	"time"
-
-	"github.com/gorilla/mux"
-)
-
-var (
-	host          string
-	port          int
-	logFilePath   string
-	databasePath  string
-	sessiondbPath string
-	globalState   *State
-)
-
-func initFlags() {
-	flag.StringVar(&host, "host", "127.0.0.1", "The host to listen on")
-	flag.StringVar(&host, "h", "127.0.0.1", "The host to listen on (shorthand)")
-
-	flag.IntVar(&port, "port", 8080, "The port to listen on")
-	flag.IntVar(&port, "p", 8080, "The port to listen on (shorthand)")
-
-	flag.StringVar(&logFilePath, "logfilepath", "./server.log", "The path to the log file")
-	flag.StringVar(&databasePath, "databasepath", "./main.db", "The path to the main database")
-	flag.StringVar(&sessiondbPath, "sessiondbpath", "./sessions.db", "The path to the session database")
-}
-
-func indexHandler(w http.ResponseWriter, r *http.Request) {
-	fmt.Fprintf(w, "Hello World from the backend")
-}
-
-func main() {
-	initFlags()
-	flag.Parse()
-
-	// log init
-	log.Println("[i] Setting up logging...")
-	logFile, err := os.OpenFile(logFilePath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0664)
-	if err != nil {
-		log.Fatal("Error opening the server.log file: ", err)
-	}
-	logger := loggingMiddleware{logFile}
-
-	// db init
-	log.Println("[i] Setting up Global State Struct...")
-	s, err := NewState()
-	if err != nil {
-		log.Fatal("Error creating the NewState(): ", err)
-	}
-	globalState = s
-
-	// session init
-	log.Println("[i] Setting up Session Storage...")
-	store, err := NewSqliteStore(sessiondbPath, "sessions", "/", 3600, []byte(os.Getenv("SESSION_KEY")))
-	if err != nil {
-		panic(err)
-	}
-	globalState.sessions = store
-
-	r := mux.NewRouter()
-	r.Use(logger.Middleware)
-	r.HandleFunc("/", indexHandler)
-
-	srv := &http.Server{
-		Handler:      r,
-		Addr:         ":8080",
-		WriteTimeout: 15 * time.Second,
-		ReadTimeout:  15 * time.Second,
-	}
-
-	log.Printf("[i] Running the server on %s", srv.Addr)
-	log.Fatal(srv.ListenAndServe())
-}