Skip to content

Commit

Permalink
fix(subsonic): route settings.view -> admin home
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Dec 20, 2021
1 parent 155c8b4 commit f9133aa
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions server/server.go
Expand Up @@ -120,20 +120,19 @@ func New(opts Options) (*Server, error) {
}

func setupMisc(r *mux.Router, ctrl *ctrlbase.Controller) {
r.HandleFunc("/",
func(w http.ResponseWriter, r *http.Request) {
// make the admin page the default
http.Redirect(w, r, ctrl.Path("/admin/home"), http.StatusSeeOther)
})
r.HandleFunc("/musicFolderSettings.view",
func(w http.ResponseWriter, r *http.Request) {
// jamstash seems to call "musicFolderSettings.view" to start a scan. notice
// that there is no "/rest/" prefix, so i doesn't fit in with the nice router,
// custom handler, middleware. etc setup that we've got in `SetupSubsonic()`.
// instead lets redirect to down there and use the scan endpoint
redirectTo := fmt.Sprintf("/rest/startScan.view?%s", r.URL.Query().Encode())
http.Redirect(w, r, ctrl.Path(redirectTo), http.StatusSeeOther)
})
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
adminHome := ctrl.Path("/admin/home")
http.Redirect(w, r, adminHome, http.StatusSeeOther)
})
// misc subsonic routes without /rest prefix
r.HandleFunc("/settings.view", func(w http.ResponseWriter, r *http.Request) {
adminHome := ctrl.Path("/admin/home")
http.Redirect(w, r, adminHome, http.StatusSeeOther)
})
r.HandleFunc("/musicFolderSettings.view", func(w http.ResponseWriter, r *http.Request) {
restScan := ctrl.Path(fmt.Sprintf("/rest/startScan.view?%s", r.URL.Query().Encode()))
http.Redirect(w, r, restScan, http.StatusSeeOther)
})
}

func setupAdmin(r *mux.Router, ctrl *ctrladmin.Controller) {
Expand Down

0 comments on commit f9133aa

Please sign in to comment.