arimelody-web/admin/music/musichttp.go

27 lines
826 B
Go
Raw Normal View History

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()
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)))
mux.ServeHTTP(w, r)
})
}