Archived
Template
1
0
This repository has been archived on 2023-12-20. You can view files and clone it, but cannot push or open issues or pull requests.
Files
2021-12-12 14:56:13 +01:00

20 lines
510 B
Go

package middleware
import (
"github.com/gin-gonic/gin"
"os"
)
// General handles the default headers that should be present in every response
func General() gin.HandlerFunc {
return func(c *gin.Context) {
c.Header("X-Content-Type-Options", "nosniff")
c.Header("X-XSS-Protection", "1; mode=block")
c.Header("X-Frame-Options", "DENY")
if os.Getenv("STRICT_TRANSPORT_SECURITY") == "true" {
c.Header("Strict-Transport-Security", "max-age=63072000; includeSubDomains; preload;")
}
c.Next()
}
}