aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go10
1 files changed, 10 insertions, 0 deletions
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")