ff49403fd5
- Add GET/PUT /api/artists/{id} for artist settings
- Update sync to create artists table entry (library settings)
- Support partial updates for monitored, path, quality/metadata profiles
- Add e2e tests for get, edit, partial update flows
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package api
|
|
|
|
import (
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/go-chi/chi/v5/middleware"
|
|
"github.com/go-chi/cors"
|
|
)
|
|
|
|
func NewRouter(h *Handlers) *chi.Mux {
|
|
r := chi.NewRouter()
|
|
|
|
r.Use(middleware.Logger)
|
|
r.Use(middleware.Recoverer)
|
|
r.Use(cors.Handler(cors.Options{
|
|
AllowedOrigins: []string{"*"},
|
|
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
|
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
|
AllowCredentials: true,
|
|
MaxAge: 300,
|
|
}))
|
|
|
|
r.Get("/health", h.Health)
|
|
|
|
r.Route("/api", func(r chi.Router) {
|
|
r.Route("/indexers", func(r chi.Router) {
|
|
r.Get("/", h.ListIndexers)
|
|
r.Post("/search", h.SearchIndexers)
|
|
})
|
|
|
|
r.Route("/torrents", func(r chi.Router) {
|
|
r.Get("/", h.ListTorrents)
|
|
r.Post("/", h.AddTorrent)
|
|
r.Get("/{hash}", h.GetTorrent)
|
|
r.Delete("/{hash}", h.RemoveTorrent)
|
|
r.Post("/{hash}/pause", h.PauseTorrent)
|
|
r.Post("/{hash}/resume", h.ResumeTorrent)
|
|
})
|
|
|
|
r.Route("/metadata", func(r chi.Router) {
|
|
r.Post("/artists/search", h.SearchArtists)
|
|
r.Get("/artists/{id}/albums", h.GetArtistAlbums)
|
|
})
|
|
|
|
r.Post("/sync", h.Sync)
|
|
|
|
r.Route("/artists", func(r chi.Router) {
|
|
r.Get("/{id}", h.GetArtist)
|
|
r.Put("/{id}", h.EditArtist)
|
|
r.Post("/{id}/refresh", h.RefreshArtist)
|
|
r.Delete("/{id}", h.DeleteArtist)
|
|
})
|
|
|
|
r.Route("/library", func(r chi.Router) {
|
|
r.Get("/artists", h.ListLibraryArtists)
|
|
r.Get("/albums", h.ListLibraryAlbums)
|
|
r.Get("/stats", h.LibraryStats)
|
|
})
|
|
})
|
|
|
|
return r
|
|
}
|