-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathexample.go
More file actions
36 lines (30 loc) · 866 Bytes
/
example.go
File metadata and controls
36 lines (30 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"log"
"github.com/gin-contrib/secure"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.Use(secure.New(secure.Config{
AllowedHosts: []string{"example.com", "ssl.example.com"},
SSLRedirect: true,
SSLHost: "ssl.example.com",
STSSeconds: 315360000,
STSIncludeSubdomains: true,
FrameDeny: true,
ContentTypeNosniff: true,
BrowserXssFilter: true,
ContentSecurityPolicy: "default-src 'self'",
IENoOpen: true,
ReferrerPolicy: "strict-origin-when-cross-origin",
SSLProxyHeaders: map[string]string{"X-Forwarded-Proto": "https"},
}))
router.GET("/ping", func(c *gin.Context) {
c.String(200, "pong")
})
// Listen and Server in 0.0.0.0:8080
if err := router.Run(); err != nil {
log.Fatal(err)
}
}