add releases page; fix HUGE static file perf regression

This commit is contained in:
ari melody 2025-10-21 17:15:26 +01:00
parent 31fd5da44b
commit 065a34a744
Signed by: ari
GPG key ID: CF99829C92678188
20 changed files with 233 additions and 73 deletions

View file

@ -47,15 +47,16 @@ func Handler(app *model.AppState) http.Handler {
mux.Handle("/register", registerAccountHandler(app))
mux.Handle("/account", requireAccount(accountIndexHandler(app)))
mux.Handle("/account/", requireAccount(http.StripPrefix("/account", accountHandler(app))))
mux.Handle("/account/", requireAccount(accountHandler(app)))
mux.Handle("/logs", requireAccount(logsHandler(app)))
mux.Handle("/release/", requireAccount(http.StripPrefix("/release", serveRelease(app))))
mux.Handle("/artist/", requireAccount(http.StripPrefix("/artist", serveArtist(app))))
mux.Handle("/track/", requireAccount(http.StripPrefix("/track", serveTrack(app))))
mux.Handle("/releases", requireAccount(serveReleases(app)))
mux.Handle("/releases/", requireAccount(serveReleases(app)))
mux.Handle("/artists/", requireAccount(serveArtists(app)))
mux.Handle("/tracks/", requireAccount(serveTracks(app)))
mux.Handle("/static/", http.StripPrefix("/static", staticHandler()))
mux.Handle("/static/", staticHandler())
mux.Handle("/", requireAccount(AdminIndexHandler(app)))
@ -470,7 +471,8 @@ var staticFS embed.FS
func staticHandler() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
file, err := staticFS.ReadFile(filepath.Join("static", filepath.Clean(r.URL.Path)))
uri := strings.TrimPrefix(r.URL.Path, "/static")
file, err := staticFS.ReadFile(filepath.Join("static", filepath.Clean(uri)))
if err != nil {
http.NotFound(w, r)
return