2025-07-15 16:40:15 +01:00
|
|
|
package music
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"arimelody-web/model"
|
|
|
|
|
"net/http"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Handler(app *model.AppState) http.Handler {
|
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
|
|
2025-11-07 17:48:06 +00:00
|
|
|
mux.Handle("/releases/", http.StripPrefix("/releases", serveReleases(app)))
|
|
|
|
|
|
|
|
|
|
mux.HandleFunc("/artists/{id}", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
serveArtist(app, r.PathValue("id")).ServeHTTP(w, r)
|
|
|
|
|
})
|
|
|
|
|
mux.Handle("/artists/", http.StripPrefix("/artists", serveArtists(app)))
|
|
|
|
|
|
|
|
|
|
mux.HandleFunc("/tracks/{id}", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
serveTrack(app, r.PathValue("id")).ServeHTTP(w, r)
|
|
|
|
|
})
|
|
|
|
|
mux.Handle("/tracks/", http.StripPrefix("/tracks", serveTracks(app)))
|
2025-07-15 16:40:15 +01:00
|
|
|
|
|
|
|
|
mux.ServeHTTP(w, r)
|
|
|
|
|
})
|
|
|
|
|
}
|