Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( // TokenCookieKey is the cookie name which contains the CSRF token. TokenCookieKey = "csrftoken" // TokenHeaderKey is the header name which contains the CSRF token. TokenHeaderKey = "X-CSRF-Token" //nolint: gosec // Authorization is the header name which contains the token. Authorization = "Authorization" )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(excludePaths []string) gin.HandlerFunc
New creates new CSRF middleware for gin.
Example ¶
package main import ( "github.com/elisasre/go-common/v2/middleware/csrf" "github.com/gin-gonic/gin" ) func main() { r := gin.New() excludePaths := []string{"/oauth2/token"} r.Use(csrf.New(excludePaths)) }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.