From b5a3d3f2b1406e8f7575766cb7e05181c3836097 Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Sun, 13 Aug 2023 22:06:45 +0200 Subject: Embed static files (css, js, ...) at compile time --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index f2aed1f..826f624 100644 --- a/main.go +++ b/main.go @@ -36,6 +36,9 @@ const UNAUTH string = "Unauthorized" //go:embed templates var tmplContent embed.FS +//go:embed static +var staticContent embed.FS + type Doc struct { Name string Size string @@ -649,7 +652,7 @@ func main() { log.Printf("baseDocDir: %s\n", baseDocDir) http.HandleFunc("/docs/", handleFileServer(baseDocDir, "/docs/")) //http.Handle("/docs/", http.StripPrefix("/docs/", http.FileServer(http.Dir("docs")))) - http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) + http.Handle("/static/", http.FileServer(http.FS(staticContent))) http.HandleFunc("/", index) //http.HandleFunc("/createuser", createuser) http.HandleFunc("/login", login) -- cgit v1.2.3