-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv1.go
More file actions
52 lines (41 loc) · 1.63 KB
/
v1.go
File metadata and controls
52 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package http
import (
"musicboxapi/configuration"
"musicboxapi/database"
"path/filepath"
"github.com/gin-gonic/gin"
)
func V1Endpoints(apiv1Group *gin.RouterGroup) {
songHandler := SongHandler{
SongTable: database.NewSongTableInstance(),
}
playlistHandler := PlaylistHandler{
PlaylistTable: database.NewPlaylistTableInstance(),
}
playlistSongHandler := PlaylistSongHandler{
PlaylistsongTable: database.NewPlaylistsongTableInstance(),
}
taskLogHandler := TaskLogHandler{
TasklogTable: database.NewTasklogTableInstance(),
}
apiv1Group.GET("/songs", songHandler.FetchSongs)
apiv1Group.GET("/playlist", playlistHandler.FetchPlaylists)
apiv1Group.GET("/playlist/:playlistId", playlistSongHandler.FetchPlaylistSongs)
// If nginx is not configured to handle http 206
if configuration.Config.UsePlayUrl {
apiv1Group.GET("/play/:sourceId", Play)
}
apiv1Group.GET("/tasklogs", taskLogHandler.FetchParentTaskLogs)
apiv1Group.GET("/tasklogs/:parentId", taskLogHandler.FetchChildTaskLogs)
apiv1Group.POST("/playlist", playlistHandler.InsertPlaylist)
apiv1Group.POST("/playlist/sync/:playlistId", playlistHandler.SyncPlaylist)
apiv1Group.POST("/playlistsong/:playlistId/:songId", playlistSongHandler.InsertPlaylistSong)
apiv1Group.POST("/download", DownloadRequest)
apiv1Group.DELETE("/playlist/:playlistId", playlistHandler.DeletePlaylist)
apiv1Group.DELETE("playlistsong/:playlistId/:songId", playlistSongHandler.DeletePlaylistSong)
// If nginx is not configured to handle it
if configuration.Config.UseImageUrl {
// Serving static files
apiv1Group.Static("/images", filepath.Join(configuration.Config.SourceFolder, "images"))
}
}