diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-05 21:01:25 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-05 21:01:25 +0200 |
commit | ce911df583e384d86018e42f9548cdf33d1c1549 (patch) | |
tree | c8bbc3ff4dce25ffacfe493e865378c6e6d59e3a /main.go | |
parent | 3be25766027178489a0c5f1f82e65f9be518c79c (diff) | |
download | cerrado-ce911df583e384d86018e42f9548cdf33d1c1549.tar.gz cerrado-ce911df583e384d86018e42f9548cdf33d1c1549.tar.bz2 cerrado-ce911df583e384d86018e42f9548cdf33d1c1549.zip |
ui: Add navbar
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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") |