From 559c9106b0cae931763e4783e85cb6cc15499b0c Mon Sep 17 00:00:00 2001 From: sentriz Date: Sun, 28 Apr 2024 13:31:59 +0100 Subject: [PATCH] remove redundant handlerutil.Redirect --- cmd/gonic/gonic.go | 2 +- handlerutil/handlerutil.go | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/cmd/gonic/gonic.go b/cmd/gonic/gonic.go index 625c348e..4548904c 100644 --- a/cmd/gonic/gonic.go +++ b/cmd/gonic/gonic.go @@ -273,7 +273,7 @@ func main() { mux.Handle("/admin/", http.StripPrefix("/admin", chain(ctrlAdmin))) mux.Handle("/rest/", http.StripPrefix("/rest", chain(trim(ctrlSubsonic)))) mux.Handle("/ping", chain(handlerutil.Message("ok"))) - mux.Handle("/", chain(handlerutil.Redirect(resolveProxyPath("/admin/home")))) + mux.Handle("/", chain(http.RedirectHandler(resolveProxyPath("/admin/home"), http.StatusSeeOther))) if *confExpvar { mux.Handle("/debug/vars", expvar.Handler()) diff --git a/handlerutil/handlerutil.go b/handlerutil/handlerutil.go index 4116dc7d..8fd27ae1 100644 --- a/handlerutil/handlerutil.go +++ b/handlerutil/handlerutil.go @@ -56,12 +56,6 @@ func BasicCORS(next http.Handler) http.Handler { }) } -func Redirect(to string) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, to, http.StatusSeeOther) - }) -} - func Message(message string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, message)