-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
Description
Anyone tried integrating this with Gin? Would something like this work?
// Create the router
r = gin.Default()
auth := restgate.New("X-Auth-Key", "X-Auth-Secret", restgate.Static, restgate.Config{Context: C, Key: []string{"12345"}, Secret: []string{"secret"}}))
// Create Gin middleware - integrate unrolled secure with Gin
authMiddleware := func() gin.HandlerFunc {
return func(c *gin.Context) {
err := auth.Process(c.Writer, c.Request)
// check(err)
// Avoid header rewrite if response is a redirection.
if status := c.Writer.Status(); status > 300 && status < 399 {
c.Abort()
}
}
}()
// use the new security middleware
r.Use(authMiddleware)