Change visibility of helper function

This commit is contained in:
Deluan 2021-05-02 15:23:51 -04:00
parent 490a7fcf52
commit 2372f1d12b

View file

@ -99,7 +99,7 @@ func (app *Router) RX(r chi.Router, pathPrefix string, constructor rest.Reposito
r.Post("/", rest.Post(constructor)) r.Post("/", rest.Post(constructor))
} }
r.Route("/{id}", func(r chi.Router) { r.Route("/{id}", func(r chi.Router) {
r.Use(UrlParams) r.Use(urlParams)
r.Get("/", rest.Get(constructor)) r.Get("/", rest.Get(constructor))
if persistable { if persistable {
r.Put("/", rest.Put(constructor)) r.Put("/", rest.Put(constructor))
@ -117,7 +117,7 @@ func (app *Router) addPlaylistTrackRoute(r chi.Router) {
getPlaylist(app.ds)(w, r) getPlaylist(app.ds)(w, r)
}) })
r.Route("/{id}", func(r chi.Router) { r.Route("/{id}", func(r chi.Router) {
r.Use(UrlParams) r.Use(urlParams)
r.Put("/", func(w http.ResponseWriter, r *http.Request) { r.Put("/", func(w http.ResponseWriter, r *http.Request) {
reorderItem(app.ds)(w, r) reorderItem(app.ds)(w, r)
}) })
@ -125,14 +125,14 @@ func (app *Router) addPlaylistTrackRoute(r chi.Router) {
deleteFromPlaylist(app.ds)(w, r) deleteFromPlaylist(app.ds)(w, r)
}) })
}) })
r.With(UrlParams).Post("/", func(w http.ResponseWriter, r *http.Request) { r.With(urlParams).Post("/", func(w http.ResponseWriter, r *http.Request) {
addToPlaylist(app.ds)(w, r) addToPlaylist(app.ds)(w, r)
}) })
}) })
} }
// Middleware to convert Chi URL params (from Context) to query params, as expected by our REST package // Middleware to convert Chi URL params (from Context) to query params, as expected by our REST package
func UrlParams(next http.Handler) http.Handler { func urlParams(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := chi.RouteContext(r.Context()) ctx := chi.RouteContext(r.Context())
parts := make([]string, 0) parts := make([]string, 0)