that's all the API create routes! + some admin UI
Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
parent
9329aa9f60
commit
494b29def3
11 changed files with 193 additions and 19 deletions
20
api/api.go
20
api/api.go
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue