This commit is contained in:
@@ -186,6 +186,36 @@ func (c *LibraryController) GetSongs(w http.ResponseWriter, r *http.Request) {
|
||||
jsonResponse(w, songs, http.StatusOK)
|
||||
}
|
||||
|
||||
func (c *LibraryController) GetSongsByArtist(w http.ResponseWriter, r *http.Request) {
|
||||
idParam := chi.URLParam(r, "id")
|
||||
id, err := strconv.Atoi(idParam)
|
||||
if err != nil {
|
||||
jsonError(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
songs, err := c.service.GetSongsByArtist(id)
|
||||
if err != nil {
|
||||
jsonError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
jsonResponse(w, songs, http.StatusOK)
|
||||
}
|
||||
|
||||
func (c *LibraryController) GetSongsByAlbum(w http.ResponseWriter, r *http.Request) {
|
||||
idParam := chi.URLParam(r, "id")
|
||||
id, err := strconv.Atoi(idParam)
|
||||
if err != nil {
|
||||
jsonError(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
songs, err := c.service.GetSongsByAlbum(id)
|
||||
if err != nil {
|
||||
jsonError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
jsonResponse(w, songs, http.StatusOK)
|
||||
}
|
||||
|
||||
func (c *LibraryController) GetArtists(w http.ResponseWriter, r *http.Request) {
|
||||
artists, err := c.service.GetArtists()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user