Serverside stuff. Mostly shuffling things around

This commit is contained in:
Melody Becker 2024-10-26 11:42:51 +02:00
parent 90667d96c7
commit be70109c43
20 changed files with 513 additions and 71 deletions

22
server/frontendRouter.go Normal file
View file

@ -0,0 +1,22 @@
package server
import (
"io/fs"
"net/http"
)
// Mounted at /
func setupFrontendRouter(interactiveFs, noscriptFs fs.FS) http.Handler {
router := http.NewServeMux()
router.Handle("/noscript/", http.StripPrefix("/noscript", http.FileServerFS(noscriptFs)))
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFileFS(w, r, interactiveFs, "index.html")
})
router.Handle("/assets/", http.FileServerFS(interactiveFs))
router.HandleFunc(
"/robots.txt",
func(w http.ResponseWriter, r *http.Request) { http.ServeFileFS(w, r, interactiveFs, "robots.txt") },
)
return router
}