(Very) basic setup.

This commit is contained in:
Marvin Blum
2023-07-17 20:51:19 +02:00
committed by Marvin Blum
parent 5c78f9dd5d
commit a30ac3f997
7 changed files with 251 additions and 0 deletions

1
cmd/admin/index.html Normal file
View File

@@ -0,0 +1 @@
<h1>Admin</h1>

32
cmd/main.go Normal file
View File

@@ -0,0 +1,32 @@
package main
import (
"embed"
"github.com/Kugelschieber/migo/db"
"github.com/go-chi/chi/v5"
"log"
"net/http"
)
var (
//go:embed admin
admin embed.FS
)
func main() {
if err := db.Init(); err != nil {
log.Fatalf("Error initializing database: %v", err)
}
defer db.Close()
router := chi.NewRouter()
router.Handle("/admin/*", http.FileServer(http.FS(admin)))
router.Handle("/admin", http.RedirectHandler("/admin/", http.StatusFound))
router.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("<h1>Hello World!</h1>"))
})
if err := http.ListenAndServe(":8080", router); err != nil {
log.Fatalf("Error starting server: %v", err)
}
}