aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2023-08-13 22:06:45 +0200
committerJulian Hurst <ark@mansus.space>2023-08-13 22:06:45 +0200
commitb5a3d3f2b1406e8f7575766cb7e05181c3836097 (patch)
treed9bbfceec1a824a69b6f57f448d9f35df999a29d /main.go
parent9795530f4433365a18a99d21ed75c3314caa279f (diff)
downloaddocspace-b5a3d3f2b1406e8f7575766cb7e05181c3836097.tar.gz
Embed static files (css, js, ...) at compile time
Diffstat (limited to 'main.go')
-rw-r--r--main.go5
1 files changed, 4 insertions, 1 deletions
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)