32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
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.HandleFunc("/music/releases/{id}/", func(w http.ResponseWriter, r *http.Request) {
|
|
serveEditRelease(app, r.PathValue("id")).ServeHTTP(w, r)
|
|
})
|
|
mux.HandleFunc("/music/releases/{id}", func(w http.ResponseWriter, r *http.Request) {
|
|
serveRelease(app, r.PathValue("id")).ServeHTTP(w, r)
|
|
})
|
|
mux.Handle("/music/releases/", serveReleases(app))
|
|
|
|
mux.HandleFunc("/music/artists/{id}", func(w http.ResponseWriter, r *http.Request) {
|
|
serveArtist(app, r.PathValue("id")).ServeHTTP(w, r)
|
|
})
|
|
mux.Handle("/music/artists/", serveArtists(app))
|
|
|
|
mux.HandleFunc("/music/tracks/{id}", func(w http.ResponseWriter, r *http.Request) {
|
|
serveTrack(app, r.PathValue("id")).ServeHTTP(w, r)
|
|
})
|
|
mux.Handle("/music/tracks/", serveTracks(app))
|
|
|
|
mux.ServeHTTP(w, r)
|
|
})
|
|
}
|