diff options
author | Alan Pearce | 2024-04-21 13:49:30 +0200 |
---|---|---|
committer | Alan Pearce | 2024-04-21 13:49:30 +0200 |
commit | c258ad4dfcd394c212073d6bd809de9754c30955 (patch) | |
tree | 6b9750c76aa5c0edf164b8fdec0a8838de15af67 /server.go | |
parent | 9ece57315f2cfee0b2fb64d1fd9fb05fb7fb6301 (diff) | |
download | website-c258ad4dfcd394c212073d6bd809de9754c30955.tar.lz website-c258ad4dfcd394c212073d6bd809de9754c30955.tar.zst website-c258ad4dfcd394c212073d6bd809de9754c30955.zip |
serve site from filesystem rather than embedding
It's cool to embed, but it requires server.go to be at the root. Also, I'd like to be able to update the built site separately in the future.
Diffstat (limited to 'server.go')
-rw-r--r-- | server.go | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/server.go b/server.go index 0835d68..935cc1e 100644 --- a/server.go +++ b/server.go @@ -1,7 +1,6 @@ package main import ( - "embed" "errors" "fmt" "io" @@ -45,9 +44,6 @@ type Host struct { Fiber *fiber.App } -//go:embed all:public/* -var fs embed.FS - var Commit string func main() { @@ -130,10 +126,10 @@ func main() { website.Use(recover.New(recover.Config{})) - files := http.FS(fs) + files := http.Dir("public") notFoundHandler := func(c *fiber.Ctx) error { c.Status(fiber.StatusNotFound).Type("html", "utf-8") - content, err := files.Open("public/404.html") + content, err := files.Open("404.html") if err != nil { c.Type("txt") return c.SendString("404 Not Found") @@ -143,7 +139,6 @@ func main() { website.Get("/404.html", notFoundHandler) website.Use("/", filesystem.New(filesystem.Config{ Root: files, - PathPrefix: "public", ContentTypeCharset: "utf-8", MaxAge: int((24 * time.Hour).Seconds()), })) |