From ce911df583e384d86018e42f9548cdf33d1c1549 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sun, 5 May 2024 21:01:25 +0200 Subject: ui: Add navbar --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 3d6411d..d2452e8 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "flag" + "io/fs" "log/slog" "net/http" "os" @@ -17,6 +18,7 @@ import ( "git.gabrielgio.me/cerrado/pkg/config" "git.gabrielgio.me/cerrado/pkg/worker" + "git.gabrielgio.me/cerrado/static" "git.gabrielgio.me/cerrado/templates" ) @@ -25,6 +27,7 @@ func main() { ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill) defer stop() if err := run(ctx); err != nil { + slog.Error("Error", "error", err) os.Exit(1) } } @@ -37,6 +40,13 @@ func run(ctx context.Context) error { flag.Parse() mux := http.NewServeMux() + + staticFs, err := fs.Sub(static.Static, ".") + if err != nil { + return err + } + + mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticFs)))) mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { slog.Info("Handling index") -- cgit v1.2.3