middleware

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AuthenticationJWTGinContextKey = "gin:context:request:header:jwt"
View Source
const AuthenticationJWTIDGinContextKey = "gin:context:request:header:jwt:id"
View Source
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL