From 2ade4a186e12960aef9d2e9f5d06439c85bb481e Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 5 Apr 2025 20:30:00 +0800 Subject: source/static-Handler shall no longer be global variables --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 4527825..8eca6a7 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ package main import ( "errors" "flag" + "io/fs" "log" "log/slog" "net" @@ -26,6 +27,16 @@ func main() { s := server{} + s.sourceHandler = http.StripPrefix( + "/-/source/", + http.FileServer(http.FS(embeddedSourceFS)), + ) + staticFS, err := fs.Sub(embeddedResourcesFS, "static") + if err != nil { + panic(err) + } + s.staticHandler = http.StripPrefix("/-/static/", http.FileServer(http.FS(staticFS))) + if err := s.loadConfig(*configPath); err != nil { slog.Error("loading configuration", "error", err) os.Exit(1) -- cgit v1.2.3