diff options
| author | Julian Hurst <ark@mansus.space> | 2023-08-13 22:06:45 +0200 |
|---|---|---|
| committer | Julian Hurst <ark@mansus.space> | 2023-08-13 22:06:45 +0200 |
| commit | b5a3d3f2b1406e8f7575766cb7e05181c3836097 (patch) | |
| tree | d9bbfceec1a824a69b6f57f448d9f35df999a29d | |
| parent | 9795530f4433365a18a99d21ed75c3314caa279f (diff) | |
| download | docspace-b5a3d3f2b1406e8f7575766cb7e05181c3836097.tar.gz | |
Embed static files (css, js, ...) at compile time
| -rw-r--r-- | main.go | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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) |
