mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-19 20:26:33 -07:00
chore: initial public commit
This commit is contained in:
commit
fc9054b78c
250 changed files with 32809 additions and 0 deletions
23
engine/handlers/get_top_tracks.go
Normal file
23
engine/handlers/get_top_tracks.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gabehf/koito/internal/db"
|
||||
"github.com/gabehf/koito/internal/logger"
|
||||
"github.com/gabehf/koito/internal/utils"
|
||||
)
|
||||
|
||||
func GetTopTracksHandler(store db.DB) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := logger.FromContext(r.Context())
|
||||
opts := OptsFromRequest(r)
|
||||
tracks, err := store.GetTopTracksPaginated(r.Context(), opts)
|
||||
if err != nil {
|
||||
l.Err(err).Msg("Failed to get top tracks")
|
||||
utils.WriteError(w, "failed to get tracks", 400)
|
||||
return
|
||||
}
|
||||
utils.WriteJSON(w, http.StatusOK, tracks)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue