|
|
|
@ -322,9 +322,25 @@ func (s *HTTPServer) handler(enableDebug bool) http.Handler {
|
|
|
|
|
fs := assetFS()
|
|
|
|
|
uifs = fs
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uifs = &redirectFS{fs: &templatedIndexFS{fs: uifs, templateVars: s.GenerateHTMLTemplateVars}}
|
|
|
|
|
mux.Handle("/robots.txt", http.FileServer(uifs))
|
|
|
|
|
mux.Handle(s.agent.config.UIContentPath, http.StripPrefix(s.agent.config.UIContentPath, http.FileServer(uifs)))
|
|
|
|
|
// create a http handler using the ui file system
|
|
|
|
|
// and the headers specified by the http_config.response_headers user config
|
|
|
|
|
uifsWithHeaders := serveHandlerWithHeaders(
|
|
|
|
|
http.FileServer(uifs),
|
|
|
|
|
s.agent.config.HTTPResponseHeaders,
|
|
|
|
|
)
|
|
|
|
|
mux.Handle(
|
|
|
|
|
"/robots.txt",
|
|
|
|
|
uifsWithHeaders,
|
|
|
|
|
)
|
|
|
|
|
mux.Handle(
|
|
|
|
|
s.agent.config.UIContentPath,
|
|
|
|
|
http.StripPrefix(
|
|
|
|
|
s.agent.config.UIContentPath,
|
|
|
|
|
uifsWithHeaders,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wrap the whole mux with a handler that bans URLs with non-printable
|
|
|
|
@ -752,6 +768,14 @@ func setHeaders(resp http.ResponseWriter, headers map[string]string) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// serveHandlerWithHeaders is used to serve a http.Handler with the specified headers
|
|
|
|
|
func serveHandlerWithHeaders(h http.Handler, headers map[string]string) http.HandlerFunc {
|
|
|
|
|
return func(resp http.ResponseWriter, req *http.Request) {
|
|
|
|
|
setHeaders(resp, headers)
|
|
|
|
|
h.ServeHTTP(resp, req)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// parseWait is used to parse the ?wait and ?index query params
|
|
|
|
|
// Returns true on error
|
|
|
|
|
func parseWait(resp http.ResponseWriter, req *http.Request, b structs.QueryOptionsCompat) bool {
|
|
|
|
|