Skip to content

Integrating with Gin #4

@dstroot

Description

@dstroot

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions