feat: translation middleware

This commit is contained in:
2026-02-19 21:13:01 +01:00
parent bbae5b1c93
commit cbc2a1a803
35 changed files with 1500 additions and 82 deletions
+38
View File
@@ -0,0 +1,38 @@
package server
import (
"io/fs"
"log/slog"
"net/http"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/web"
)
// registerStatic registers all the static files.
func registerStatic(mux *http.ServeMux) {
fileSystem := web.GetStaticFS()
// we still use go's fileServer to avoid unnecessary implementation
fileServer := http.FileServer(http.FS(fileSystem))
err := fs.WalkDir(fileSystem, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
path = "/" + path
slog.Info("registering file", "path", path)
mux.Handle(path, fileServer)
return nil
})
if err != nil {
slog.Error("could not register static files", "err", err)
panic(err)
}
}