re-re-arrange error checks

This commit is contained in:
Alan Bernstein 2020-09-01 11:32:58 -05:00
parent 4ce3879e2c
commit 007b3ffc3c

View file

@ -478,6 +478,15 @@ func NewStatikHandler(h *Handler) statikHandler {
}
func (s statikHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.UserAgent(), "curl") {
msg := "Welcome. Pilosa v" + s.handler.api.Version() + " is running. Visit https://www.pilosa.com/docs/ for more information."
if s.statikFS != nil {
msg += " Try the Web UI by visiting this URL in your browser."
}
http.Error(w, msg, http.StatusNotFound)
return
}
if s.statikFS == nil {
msg := "Web UI is not available. Please run `make generate-statik` before building Pilosa with `make install`."
s.handler.logger.Printf(msg)
@ -485,11 +494,6 @@ func (s statikHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
if strings.HasPrefix(r.UserAgent(), "curl") {
http.Error(w, "Welcome. Pilosa is running. Visit https://www.pilosa.com/docs/ for more information or try the Web UI by visiting this URL in your browser.", http.StatusNotFound)
return
}
// /vds is a front-end route, not a backend route. Without this check, refreshing at /vds
// will request a nonexistent resource and return 404.
if r.URL.String() == "/vds" {