Revert UI->Lattice name change, correct the ordering of error checks in statikHandler

This commit is contained in:
Alan Bernstein 2020-08-31 17:41:57 -05:00
parent a597a79e2d
commit 4ce3879e2c
2 changed files with 10 additions and 9 deletions

View file

@ -39,7 +39,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) {
SetTLSConfig(flags, "", &srv.Config.TLS.CertificatePath, &srv.Config.TLS.CertificateKeyPath, &srv.Config.TLS.CACertPath, &srv.Config.TLS.SkipVerify, &srv.Config.TLS.EnableClientVerification)
// Handler
flags.StringSliceVarP(&srv.Config.Handler.AllowedOrigins, "handler.allowed-origins", "", []string{}, "Comma separated list of allowed origin URIs (for CORS/Lattice UI).")
flags.StringSliceVarP(&srv.Config.Handler.AllowedOrigins, "handler.allowed-origins", "", []string{}, "Comma separated list of allowed origin URIs (for CORS/Web UI).")
// Cluster
flags.BoolVarP(&srv.Config.Cluster.Disabled, "cluster.disabled", "", srv.Config.Cluster.Disabled, "Disabled multi-node cluster communication (used for testing)")

View file

@ -468,7 +468,7 @@ type statikHandler struct {
func NewStatikHandler(h *Handler) statikHandler {
fs, err := h.fileSystem.New()
if err == nil {
h.logger.Printf("enabled Lattice UI (%s) at %s", h.api.LatticeVersion(), h.api.Node().URI)
h.logger.Printf("enabled Web UI (%s) at %s", h.api.LatticeVersion(), h.api.Node().URI)
}
return statikHandler{
@ -478,8 +478,15 @@ func NewStatikHandler(h *Handler) statikHandler {
}
func (s statikHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
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)
http.Error(w, msg, http.StatusInternalServerError)
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 Lattice UI by visiting this URL in your browser.", http.StatusNotFound)
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
}
@ -490,12 +497,6 @@ func (s statikHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r.URL = url
}
if s.statikFS == nil {
msg := "Lattice UI is not available. Please run `make generate-statik` before building Pilosa with `make install`."
s.handler.logger.Printf(msg)
http.Error(w, msg, http.StatusInternalServerError)
return
}
http.FileServer(s.statikFS).ServeHTTP(w, r)
}