server: add "Cache-Control: max-age=0" response header

This commit is contained in:
Justin Cranford 2024-09-29 04:11:13 -04:00
parent 03608cb46e
commit 5f4ebeba95

View File

@ -1092,6 +1092,13 @@ func allowedHostsMiddleware(addr net.Addr) gin.HandlerFunc {
}
}
func CacheControlMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
c.Header("Cache-Control", "max-age=0")
c.Next()
}
}
func (s *Server) GenerateRoutes() http.Handler {
config := cors.DefaultConfig()
config.AllowWildcard = true
@ -1105,6 +1112,7 @@ func (s *Server) GenerateRoutes() http.Handler {
r := gin.Default()
r.Use(
CacheControlMiddleware(),
cors.New(config),
allowedHostsMiddleware(s.addr),
)