2024-08-02 21:48:26 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"arimelody.me/arimelody.me/admin"
|
|
|
|
music "arimelody.me/arimelody.me/music/view"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Handler() http.Handler {
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
|
|
|
|
mux.Handle("/v1/artist/", http.StripPrefix("/v1/artist", ServeArtist()))
|
|
|
|
mux.Handle("/v1/artist", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
switch r.Method {
|
|
|
|
case http.MethodGet:
|
|
|
|
ServeAllArtists().ServeHTTP(w, r)
|
|
|
|
return
|
|
|
|
case http.MethodPost:
|
|
|
|
admin.MustAuthorise(CreateArtist()).ServeHTTP(w, r)
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
http.NotFound(w, r)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}))
|
2024-08-02 23:27:30 +00:00
|
|
|
|
2024-08-02 21:48:26 +00:00
|
|
|
mux.Handle("/v1/music/", http.StripPrefix("/v1/music", music.ServeRelease()))
|
|
|
|
mux.Handle("/v1/music", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
switch r.Method {
|
|
|
|
case http.MethodGet:
|
|
|
|
ServeCatalog().ServeHTTP(w, r)
|
|
|
|
return
|
|
|
|
case http.MethodPost:
|
|
|
|
admin.MustAuthorise(CreateRelease()).ServeHTTP(w, r)
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
http.NotFound(w, r)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
|
2024-08-02 23:27:30 +00:00
|
|
|
mux.Handle("/v1/musiccredit", CreateCredit())
|
|
|
|
mux.Handle("/v1/track", CreateTrack())
|
|
|
|
|
2024-08-02 21:48:26 +00:00
|
|
|
return mux
|
|
|
|
}
|