Skip to content

Commit

Permalink
better func name, swap conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbailey committed Nov 11, 2019
1 parent d91a5e6 commit 29585dd
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions command/agent/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (s *HTTPServer) registerHandlers(enableDebug bool) {
w.Write([]byte(stubHTML))
})
}
s.mux.Handle("/", handleRootRedirect())
s.mux.Handle("/", handleRootFallthrough())

if enableDebug {
s.mux.HandleFunc("/debug/pprof/", pprof.Index)
Expand Down Expand Up @@ -275,15 +275,13 @@ func handleUI(h http.Handler) http.Handler {
})
}

func handleRootRedirect() http.Handler {
func handleRootFallthrough() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
if req.URL.Path != "/" {
if req.URL.Path == "/" {
http.Redirect(w, req, "/ui/", 307)
} else {
w.WriteHeader(http.StatusNotFound)
return
}

http.Redirect(w, req, "/ui/", 307)
return
})
}

Expand Down

0 comments on commit 29585dd

Please sign in to comment.