that's all the API create routes! + some admin UI

Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
ari melody 2024-08-03 15:02:01 +01:00
parent 9329aa9f60
commit 494b29def3
11 changed files with 193 additions and 19 deletions

View file

@ -25,7 +25,19 @@ func Handler() http.Handler {
}
}))
mux.Handle("/v1/music/", http.StripPrefix("/v1/music", music.ServeRelease()))
mux.Handle("/v1/music/", http.StripPrefix("/v1/music", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
music.ServeRelease().ServeHTTP(w, r)
return
case http.MethodDelete:
admin.MustAuthorise(DeleteRelease()).ServeHTTP(w, r)
return
default:
http.NotFound(w, r)
return
}
})))
mux.Handle("/v1/music", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
@ -34,13 +46,17 @@ func Handler() http.Handler {
case http.MethodPost:
admin.MustAuthorise(CreateRelease()).ServeHTTP(w, r)
return
case http.MethodDelete:
admin.MustAuthorise(DeleteRelease()).ServeHTTP(w, r)
return
default:
http.NotFound(w, r)
return
}
}))
mux.Handle("/v1/musiccredit", CreateCredit())
mux.Handle("/v1/musiccredit", CreateMusicCredit())
mux.Handle("/v1/musiclink", CreateMusicLink())
mux.Handle("/v1/track", CreateTrack())
return mux