|
|
|
@ -394,26 +394,24 @@ func Start() error {
@@ -394,26 +394,24 @@ func Start() error {
|
|
|
|
|
// Optional public static files
|
|
|
|
|
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir(config.PublicFilesPath)))) |
|
|
|
|
|
|
|
|
|
// Redirect /embed/chat
|
|
|
|
|
http.HandleFunc("/embed/chat/", func(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
if r.URL.Path == "/embed/chat/" || r.URL.Path == "/embed/chat" { |
|
|
|
|
http.Redirect(w, r, "/embed/chat/readonly", http.StatusTemporaryRedirect) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
port := config.WebServerPort |
|
|
|
|
ip := config.WebServerIP |
|
|
|
|
|
|
|
|
|
h2s := &http2.Server{} |
|
|
|
|
|
|
|
|
|
// Create a custom mux handler to intercept the /debug/vars endpoint.
|
|
|
|
|
// This is a hack because Prometheus enables this endpoint by default
|
|
|
|
|
// due to its use of expvar and we do not want this exposed.
|
|
|
|
|
h2s := &http2.Server{} |
|
|
|
|
defaultMux := h2c.NewHandler(http.DefaultServeMux, h2s) |
|
|
|
|
m := http.NewServeMux() |
|
|
|
|
|
|
|
|
|
m.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
if r.URL.Path == "/debug/vars" { |
|
|
|
|
w.WriteHeader(http.StatusNotFound) |
|
|
|
|
return |
|
|
|
|
} else if r.URL.Path == "/embed/chat/" || r.URL.Path == "/embed/chat" { |
|
|
|
|
// Redirect /embed/chat
|
|
|
|
|
http.Redirect(w, r, "/embed/chat/readonly", http.StatusTemporaryRedirect) |
|
|
|
|
} else { |
|
|
|
|
defaultMux.ServeHTTP(w, r) |
|
|
|
|
} |
|
|
|
|