Replace all utils.Param* with req.Params

This commit is contained in:
Deluan
2023-12-21 17:41:09 -05:00
parent 00597e01e9
commit dfcc189cff
27 changed files with 269 additions and 513 deletions
+7 -5
View File
@@ -10,10 +10,10 @@ import (
"github.com/navidrome/navidrome/core/artwork"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/utils"
"github.com/navidrome/navidrome/utils/req"
)
func (p *Router) handleImages(w http.ResponseWriter, r *http.Request) {
func (pub *Router) handleImages(w http.ResponseWriter, r *http.Request) {
// If context is already canceled, discard request without further processing
if r.Context().Err() != nil {
return
@@ -21,7 +21,9 @@ func (p *Router) handleImages(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
defer cancel()
id := r.URL.Query().Get(":id")
p := req.Params(r)
id, _ := p.String(":id")
if id == "" {
http.Error(w, "invalid id", http.StatusBadRequest)
return
@@ -32,9 +34,9 @@ func (p *Router) handleImages(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
size := utils.ParamInt(r, "size", 0)
size := p.IntOr("size", 0)
imgReader, lastUpdate, err := p.artwork.Get(ctx, artId, size)
imgReader, lastUpdate, err := pub.artwork.Get(ctx, artId, size)
switch {
case errors.Is(err, context.Canceled):
return