Documentation
¶
Index ¶
Constants ¶
const AuthenticationJWTGinContextKey = "gin:context:request:header:jwt"
const AuthenticationJWTIDGinContextKey = "gin:context:request:header:jwt:id"
const AuthenticationJWTRoleGinContextKey = "gin:context:request:header:jwt:role"
Variables ¶
This section is empty.
Functions ¶
func Authentication ¶
func Authentication() gin.HandlerFunc
Authentication returns a 401 when no user is found or when token validation fails
func CORS ¶
func CORS() gin.HandlerFunc
func CheckRole ¶
func CheckRole(allowed []string) gin.HandlerFunc
func NoMethod ¶
func NoMethod() gin.HandlerFunc
NoMethod returns a 405 envelope (register via engine.NoMethod).
func NoRoute ¶
func NoRoute() gin.HandlerFunc
NoRoute returns a 404 envelope (register via engine.NoRoute).
func Recovery ¶
func Recovery() gin.HandlerFunc
Recovery replaces gin's default recovery middleware. It catches panics and formats them as envelope error responses instead of returning a plain 500 text body.
func WrapErrors ¶
func WrapErrors() gin.HandlerFunc
WrapErrors re-wraps any response whose body was written with a raw status code (e.g. c.AbortWithStatus(401)) so it still conforms to the envelope shape. It runs *after* handlers via c.Next().
Note: if a handler already wrote JSON via response.Data / response.Error this middleware is a no-op—it only acts when the response body is empty.
Types ¶
This section is empty.