diff options
author | Alan Pearce | 2024-04-21 20:50:10 +0200 |
---|---|---|
committer | Alan Pearce | 2024-04-21 21:49:21 +0200 |
commit | a10c8466b4bf81f9ddd356a2da90e8e5e9b360a5 (patch) | |
tree | 63a4182a2a3d8e847609f42c5dbe497cda25379e /cmd/server/server.go | |
parent | bbda985b3aec721a7d972d76780ca981140f6f3c (diff) | |
download | website-a10c8466b4bf81f9ddd356a2da90e8e5e9b360a5.tar.lz website-a10c8466b4bf81f9ddd356a2da90e8e5e9b360a5.tar.zst website-a10c8466b4bf81f9ddd356a2da90e8e5e9b360a5.zip |
split output directories into website/{public,private}
Diffstat (limited to 'cmd/server/server.go')
-rw-r--r-- | cmd/server/server.go | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/cmd/server/server.go b/cmd/server/server.go index 935cc1e..cc1821a 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -126,23 +126,22 @@ func main() { website.Use(recover.New(recover.Config{})) - files := http.Dir("public") - notFoundHandler := func(c *fiber.Ctx) error { + prefix := "website/public" + publicFiles := http.Dir(prefix) + website.Use("/", filesystem.New(filesystem.Config{ + Root: publicFiles, + ContentTypeCharset: "utf-8", + MaxAge: int((24 * time.Hour).Seconds()), + })) + website.Use(func(c *fiber.Ctx) error { c.Status(fiber.StatusNotFound).Type("html", "utf-8") - content, err := files.Open("404.html") + content, err := os.Open("website/private/404.html") if err != nil { c.Type("txt") return c.SendString("404 Not Found") } return c.SendStream(content) - } - website.Get("/404.html", notFoundHandler) - website.Use("/", filesystem.New(filesystem.Config{ - Root: files, - ContentTypeCharset: "utf-8", - MaxAge: int((24 * time.Hour).Seconds()), - })) - website.Use(notFoundHandler) + }) hosts[runtimeConfig.BaseURL.Host] = &Host{website} toplevel := fiber.New(fiber.Config{ |