Handle exporting playlists as m3u files
This commit is contained in:
+3
-15
@@ -104,24 +104,12 @@ func (app *Router) RX(r chi.Router, pathPrefix string, constructor rest.Reposito
|
||||
type restHandler = func(rest.RepositoryConstructor, ...rest.Logger) http.HandlerFunc
|
||||
|
||||
func (app *Router) addPlaylistTrackRoute(r chi.Router) {
|
||||
// Add a middleware to capture the playlistId
|
||||
wrapper := func(f restHandler) http.HandlerFunc {
|
||||
return func(res http.ResponseWriter, req *http.Request) {
|
||||
c := func(ctx context.Context) rest.Repository {
|
||||
plsRepo := app.ds.Resource(ctx, model.Playlist{})
|
||||
plsId := chi.URLParam(req, "playlistId")
|
||||
return plsRepo.(model.PlaylistRepository).Tracks(plsId)
|
||||
}
|
||||
|
||||
f(c).ServeHTTP(res, req)
|
||||
}
|
||||
}
|
||||
|
||||
r.Route("/playlist/{playlistId}/tracks", func(r chi.Router) {
|
||||
r.Get("/", wrapper(rest.GetAll))
|
||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
getPlaylist(app.ds)(w, r)
|
||||
})
|
||||
r.Route("/{id}", func(r chi.Router) {
|
||||
r.Use(UrlParams)
|
||||
r.Get("/", wrapper(rest.Get))
|
||||
r.Put("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
reorderItem(app.ds)(w, r)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user