server: add "Cache-Control: max-age=0" response header
This commit is contained in:
parent
03608cb46e
commit
5f4ebeba95
@ -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 {
|
func (s *Server) GenerateRoutes() http.Handler {
|
||||||
config := cors.DefaultConfig()
|
config := cors.DefaultConfig()
|
||||||
config.AllowWildcard = true
|
config.AllowWildcard = true
|
||||||
@ -1105,6 +1112,7 @@ func (s *Server) GenerateRoutes() http.Handler {
|
|||||||
|
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
r.Use(
|
r.Use(
|
||||||
|
CacheControlMiddleware(),
|
||||||
cors.New(config),
|
cors.New(config),
|
||||||
allowedHostsMiddleware(s.addr),
|
allowedHostsMiddleware(s.addr),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user