refactor: remove superfluous (and untested) code
This commit is contained in:
parent
72f0a6fb66
commit
fc06163b5a
2 changed files with 6 additions and 22 deletions
|
|
@ -68,13 +68,12 @@ func (api *Router) routes() http.Handler {
|
||||||
H(r, "getIndexes", c.GetIndexes)
|
H(r, "getIndexes", c.GetIndexes)
|
||||||
H(r, "getArtists", c.GetArtists)
|
H(r, "getArtists", c.GetArtists)
|
||||||
H(r, "getGenres", c.GetGenres)
|
H(r, "getGenres", c.GetGenres)
|
||||||
reqParams := r.With(requiredParams("id"))
|
H(r, "getMusicDirectory", c.GetMusicDirectory)
|
||||||
H(reqParams, "getMusicDirectory", c.GetMusicDirectory)
|
H(r, "getArtist", c.GetArtist)
|
||||||
H(reqParams, "getArtist", c.GetArtist)
|
H(r, "getAlbum", c.GetAlbum)
|
||||||
H(reqParams, "getAlbum", c.GetAlbum)
|
H(r, "getSong", c.GetSong)
|
||||||
H(reqParams, "getSong", c.GetSong)
|
H(r, "getArtistInfo", c.GetArtistInfo)
|
||||||
H(reqParams, "getArtistInfo", c.GetArtistInfo)
|
H(r, "getArtistInfo2", c.GetArtistInfo2)
|
||||||
H(reqParams, "getArtistInfo2", c.GetArtistInfo2)
|
|
||||||
})
|
})
|
||||||
r.Group(func(r chi.Router) {
|
r.Group(func(r chi.Router) {
|
||||||
c := initAlbumListController(api)
|
c := initAlbumListController(api)
|
||||||
|
|
|
||||||
|
|
@ -89,18 +89,3 @@ func authenticate(users engine.Users) func(next http.Handler) http.Handler {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func requiredParams(params ...string) func(next http.Handler) http.Handler {
|
|
||||||
return func(next http.Handler) http.Handler {
|
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
for _, p := range params {
|
|
||||||
_, err := RequiredParamString(r, p, fmt.Sprintf("%s parameter is required", p))
|
|
||||||
if err != nil {
|
|
||||||
SendError(w, r, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next.ServeHTTP(w, r)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue