Refactor routing, changes API URLs (#1171)
* Make authentication part of the server, so it can be reused outside the Native API This commit has broken tests after a rebase * Serve frontend assets from `server`, and not from Native API * Change Native API URL * Fix auth tests * Refactor server authentication * Simplify authProvider, now subsonic token+salt comes from the server * Don't send JWT token to UI when authenticated via Request Header * Enable ReverseProxyWhitelist to be read from environment
This commit is contained in:
@@ -24,6 +24,7 @@ const Version = "1.16.1"
|
||||
type handler = func(http.ResponseWriter, *http.Request) (*responses.Subsonic, error)
|
||||
|
||||
type Router struct {
|
||||
http.Handler
|
||||
DataStore model.DataStore
|
||||
Artwork core.Artwork
|
||||
Streamer core.MediaStreamer
|
||||
@@ -32,8 +33,6 @@ type Router struct {
|
||||
ExternalMetadata core.ExternalMetadata
|
||||
Scanner scanner.Scanner
|
||||
Broker events.Broker
|
||||
|
||||
mux http.Handler
|
||||
}
|
||||
|
||||
func New(ds model.DataStore, artwork core.Artwork, streamer core.MediaStreamer, archiver core.Archiver, players core.Players,
|
||||
@@ -48,16 +47,10 @@ func New(ds model.DataStore, artwork core.Artwork, streamer core.MediaStreamer,
|
||||
Scanner: scanner,
|
||||
Broker: broker,
|
||||
}
|
||||
r.mux = r.routes()
|
||||
r.Handler = r.routes()
|
||||
return r
|
||||
}
|
||||
|
||||
func (api *Router) Setup(path string) {}
|
||||
|
||||
func (api *Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
api.mux.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func (api *Router) routes() http.Handler {
|
||||
r := chi.NewRouter()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user