add releases page; fix HUGE static file perf regression
This commit is contained in:
parent
31fd5da44b
commit
065a34a744
20 changed files with 233 additions and 73 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue