|
@@ -1234,7 +1234,6 @@ func (s *httpdServer) initializeRouter() {
|
|
|
s.router.Use(s.parseHeaders)
|
|
|
s.router.Use(logger.NewStructuredLogger(logger.GetLogger()))
|
|
|
s.router.Use(middleware.Recoverer)
|
|
|
- s.router.Use(middleware.Maybe(s.checkConnection, s.mustCheckPath))
|
|
|
if s.binding.Security.Enabled {
|
|
|
secureMiddleware := secure.New(secure.Options{
|
|
|
AllowedHosts: s.binding.Security.AllowedHosts,
|
|
@@ -1250,6 +1249,9 @@ func (s *httpdServer) initializeRouter() {
|
|
|
CrossOriginOpenerPolicy: s.binding.Security.CrossOriginOpenerPolicy,
|
|
|
})
|
|
|
secureMiddleware.SetBadHostHandler(http.HandlerFunc(s.badHostHandler))
|
|
|
+ if s.binding.Security.CacheControl == "private" {
|
|
|
+ s.router.Use(cacheControlMiddleware)
|
|
|
+ }
|
|
|
s.router.Use(secureMiddleware.Handler)
|
|
|
if s.binding.Security.HTTPSRedirect {
|
|
|
s.router.Use(s.binding.Security.redirectHandler)
|
|
@@ -1270,6 +1272,7 @@ func (s *httpdServer) initializeRouter() {
|
|
|
})
|
|
|
s.router.Use(c.Handler)
|
|
|
}
|
|
|
+ s.router.Use(middleware.Maybe(s.checkConnection, s.mustCheckPath))
|
|
|
s.router.Use(middleware.GetHead)
|
|
|
s.router.Use(middleware.Maybe(middleware.StripSlashes, s.mustStripSlash))
|
|
|
|
|
@@ -1479,6 +1482,7 @@ func (s *httpdServer) initializeRouter() {
|
|
|
|
|
|
if s.renderOpenAPI {
|
|
|
s.router.Group(func(router chi.Router) {
|
|
|
+ router.Use(cleanCacheControlMiddleware)
|
|
|
router.Use(compressor.Handler)
|
|
|
serveStaticDir(router, webOpenAPIPath, s.openAPIPath, false)
|
|
|
})
|
|
@@ -1487,6 +1491,7 @@ func (s *httpdServer) initializeRouter() {
|
|
|
|
|
|
if s.enableWebAdmin || s.enableWebClient {
|
|
|
s.router.Group(func(router chi.Router) {
|
|
|
+ router.Use(cleanCacheControlMiddleware)
|
|
|
router.Use(compressor.Handler)
|
|
|
serveStaticDir(router, webStaticFilesPath, s.staticFilesPath, true)
|
|
|
})
|
|
@@ -1524,12 +1529,12 @@ func (s *httpdServer) setupWebClientRoutes() {
|
|
|
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
|
|
|
http.Redirect(w, r, webClientLoginPath, http.StatusFound)
|
|
|
})
|
|
|
- s.router.Get(path.Join(webStaticFilesPath, "branding/webclient/logo.png"),
|
|
|
+ s.router.With(cleanCacheControlMiddleware).Get(path.Join(webStaticFilesPath, "branding/webclient/logo.png"),
|
|
|
func(w http.ResponseWriter, r *http.Request) {
|
|
|
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
|
|
|
renderPNGImage(w, r, dbBrandingConfig.getWebClientLogo())
|
|
|
})
|
|
|
- s.router.Get(path.Join(webStaticFilesPath, "branding/webclient/favicon.png"),
|
|
|
+ s.router.With(cleanCacheControlMiddleware).Get(path.Join(webStaticFilesPath, "branding/webclient/favicon.png"),
|
|
|
func(w http.ResponseWriter, r *http.Request) {
|
|
|
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
|
|
|
renderPNGImage(w, r, dbBrandingConfig.getWebClientFavicon())
|
|
@@ -1657,12 +1662,12 @@ func (s *httpdServer) setupWebAdminRoutes() {
|
|
|
r.Body = http.MaxBytesReader(w, r.Body, maxLoginBodySize)
|
|
|
s.redirectToWebPath(w, r, webAdminLoginPath)
|
|
|
})
|
|
|
- s.router.Get(path.Join(webStaticFilesPath, "branding/webadmin/logo.png"),
|
|
|
+ s.router.With(cleanCacheControlMiddleware).Get(path.Join(webStaticFilesPath, "branding/webadmin/logo.png"),
|
|
|
func(w http.ResponseWriter, r *http.Request) {
|
|
|
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
|
|
|
renderPNGImage(w, r, dbBrandingConfig.getWebAdminLogo())
|
|
|
})
|
|
|
- s.router.Get(path.Join(webStaticFilesPath, "branding/webadmin/favicon.png"),
|
|
|
+ s.router.With(cleanCacheControlMiddleware).Get(path.Join(webStaticFilesPath, "branding/webadmin/favicon.png"),
|
|
|
func(w http.ResponseWriter, r *http.Request) {
|
|
|
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
|
|
|
renderPNGImage(w, r, dbBrandingConfig.getWebAdminFavicon())
|