实现音频服务api
This commit is contained in:
10
main.go
10
main.go
@@ -21,8 +21,12 @@ func main() {
|
||||
r.Use(middleware.Logger)
|
||||
|
||||
libraryRepo := repository.NewLibraryRepository(GetDB())
|
||||
songRepo := repository.NewSongRepository(GetDB())
|
||||
mediaRepo := repository.NewMediaRepository(GetDB())
|
||||
libraryService := service.NewLibraryService(libraryRepo)
|
||||
songService := service.NewSongService(songRepo, mediaRepo)
|
||||
libraryController := controller.NewLibraryController(libraryService)
|
||||
songController := controller.NewSongController(songService)
|
||||
|
||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("Hello World!"))
|
||||
@@ -39,8 +43,12 @@ func main() {
|
||||
r.Get("/{id}/songs", libraryController.GetSongs)
|
||||
})
|
||||
|
||||
r.Route("/api/songs", func(r chi.Router) {
|
||||
r.Get("/", songController.GetAllWithDetails)
|
||||
r.Get("/{id}/stream", songController.Stream)
|
||||
})
|
||||
|
||||
r.Route("/api", func(r chi.Router) {
|
||||
r.Get("/songs", libraryController.GetAllSongs)
|
||||
r.Get("/artists", libraryController.GetArtists)
|
||||
r.Get("/albums", libraryController.GetAlbums)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user