Gin

Protect your gin-gonic applications using the official Coraza Middleware.

Installing

Import the middleware using:

go get github.com/jptosso/coraza-gin

Using the middleware

Add the middleware to your code:

import(
    //...
    "github.com/jptosso/coraza-waf"
    "github.com/jptosso/coraza-waf/seclang"
    corazagin"github.com/jptosso/coraza-gin"
)
func main() {
    // Creates a router without any middleware by default
    r := gin.New()
    waf := coraza.NewWaf()
    // Add some rules...
    // Use the Coraza Gin Middleware
    r.Use(corazagin.Coraza(waf))

    // Per route middleware, you can add as many as you desire.
    r.GET("/mypath", MyFunction(), Endpoint)

    // Listen and serve on 0.0.0.0:8080
    r.Run(":8080")
}

Additional options

Additional options like error pages will come in the near future.

Edit this page on GitHub