Skip to content
Snippets Groups Projects
Verified Commit f22f40f2 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: remove nestes routes

parent ca99f1f3
Branches
No related tags found
No related merge requests found
......@@ -80,37 +80,7 @@ func InstallHTTPHandler(r *gin.RouterGroup, st *store.Store, im *importer.Import
shows.GET("", api.ListShows)
shows.POST(":show-id", api.CreateShow)
shows.DELETE(":show-id", api.DeleteShow)
// deprecated -> /imports
shows.GET(":show-id/imports", api.ListImportsOfShow)
// Show/Files: deprecated -> /files
deprecated := shows.Group(":show-id/files")
{
deprecated.GET("", api.ListFilesOfShow)
deprecated.POST("", api.CreateFileForShow)
deprecated.GET(":file-id", api.ReadFileOfShow)
deprecated.PATCH(":file-id", api.PatchFileOfShow)
deprecated.DELETE(":file-id", api.DeleteFileOfShow)
deprecated.GET(":file-id/usage", api.ReadUsageOfFile)
deprecated.GET(":file-id/logs", api.ReadLogsOfFile)
deprecated.GET(":file-id/import", api.ReadImportOfFile)
deprecated.DELETE(":file-id/import", api.CancelImportOfFile)
// TODO: distignuish between flow.js and simple upload using the content type?!?
deprecated.PUT(":file-id/upload", api.UploadFileSimple)
deprecated.POST(":file-id/upload", api.UploadFileFlowJS)
deprecated.GET(":file-id/upload", api.TestFileFlowJS)
}
// Show/Playlists: deprecated -> /playlists
deprecated2 := shows.Group(":show-id/playlists")
{
deprecated2.GET("", api.ListPlaylistsOfShow)
deprecated2.POST("", api.CreatePlaylistForShow)
deprecated2.GET(":playlist-id", api.ReadPlaylistOfShow)
deprecated2.PUT(":playlist-id", api.UpdatePlaylistOfShow)
deprecated2.DELETE(":playlist-id", api.DeletePlaylistOfShow)
}
}
imports := r.Group("imports")
......@@ -120,9 +90,9 @@ func InstallHTTPHandler(r *gin.RouterGroup, st *store.Store, im *importer.Import
playlists := r.Group("playlists")
{
playlists.GET("", api.ListPlaylists) // behaves like ListPlaylistsOfShow with ?showID
playlists.GET("", api.ListPlaylists)
playlists.POST("", api.CreatePlaylistForShow)
playlists.GET(":playlist-id", api.ReadPlaylist) // behaves like ReadPlaylistOfShow with ?showID
playlists.GET(":playlist-id", api.ReadPlaylist)
playlists.PUT(":playlist-id", api.UpdatePlaylistOfShow)
playlists.DELETE(":playlist-id", api.DeletePlaylistOfShow)
}
......@@ -138,6 +108,7 @@ func InstallHTTPHandler(r *gin.RouterGroup, st *store.Store, im *importer.Import
files.GET(":file-id/logs", api.ReadLogsOfFile)
files.GET(":file-id/import", api.ReadImportOfFile)
files.DELETE(":file-id/import", api.CancelImportOfFile)
// TODO: distinguish between flow.js and simple upload using the content type?!?
files.PUT(":file-id/upload", api.UploadFileSimple)
files.POST(":file-id/upload", api.UploadFileFlowJS)
files.GET(":file-id/upload", api.TestFileFlowJS)
......
......@@ -300,8 +300,6 @@ func (api *API) DeleteFileOfShow(c *gin.Context) {
// @Failure 404 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/files/{id}/usage [get]
//
// TODO: remove this together with nested routes
func (api *API) ReadUsageOfFile(c *gin.Context) {
fileID, err := idFromString(c.Param("file-id"))
if err != nil {
......
......@@ -25,43 +25,6 @@ import (
"net/http"
)
// ListPlaylistsOfShow lists playlists.
//
// @Summary List playlists
// @Description Lists playlists of show.
// @Produce json
// @Param showId query int true "ID of the show"
// @Param limit query int false "Limit number of results"
// @Param offset query int false "Start listing from offset"
// @Success 200 {object} PlaylistsListing
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/playlists [get]
//
// TODO: remove together with nested routes
func (api *API) ListPlaylistsOfShow(c *gin.Context) {
showID, err := getShowID(c)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: "invalid showId: " + err.Error()})
}
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
offset, limit, ok := getPaginationParameter(c)
if !ok {
return
}
playlists, err := api.store.ListPlaylists(showID, offset, limit)
if err != nil {
sendError(c, err)
return
}
c.JSON(http.StatusOK, PlaylistsListing{playlists})
}
// CreatePlaylistForShow creates a new playlist.
//
// @Summary Create playlist
......@@ -93,44 +56,6 @@ func (api *API) CreatePlaylistForShow(c *gin.Context) {
c.JSON(http.StatusCreated, playlist)
}
// ReadPlaylistOfShow retrieves a playlist of a show.
//
// @Summary Retrieve playlist
// @Description Retrieves a playlist of a show.
// @Produce json
// @Param showId query int true "ID of the show"
// @Param id path int true "ID of the playlist"
// @Success 200 {object} store.Playlist
// @Failure 400 {object} ErrorResponse
// @Failure 403 {object} ErrorResponse
// @Failure 404 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/playlists/{id} [get]
//
// TODO: remove this together with nested routes
func (api *API) ReadPlaylistOfShow(c *gin.Context) {
showID, err := getShowID(c)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: "invalid showId: " + err.Error()})
return
}
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
id, err := idFromString(c.Param("playlist-id"))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: "invalid playlist-id: " + err.Error()})
return
}
playlist, err := api.store.GetPlaylist(showID, id)
if err != nil {
sendError(c, err)
return
}
c.JSON(http.StatusOK, playlist)
}
// UpdatePlaylistOfShow updates a playlist of a show.
//
// @Summary Update playlist
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment