middleware

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JWT_CLAIMS is a key to get the claims parsed by the Protect middleware in echo.Context.
	JWT_CLAIMS = "JWT_CLAIMS"
)
View Source
const (
	// REQUEST_ID_LENGTH is the length of each request id.
	REQUEST_ID_LENGTH = 12
)
View Source
const (
	STRUCT_TYPE_KEY string = "structype"
)

Variables

View Source
var ErrNoJwtClaims error = errors.New("JWT claims not found in echo context")

Functions

func GetJwtClaimsFromContext

func GetJwtClaimsFromContext(c echo.Context) (*jwt.JwtClaims, error)

Tries to get the jwt claims set by the Protect() middleware in the echo context.

func Logger

func Logger() echo.MiddlewareFunc

Logger is a middleware that logs the request and response basic information.

func Protect

func Protect() echo.MiddlewareFunc

Protect is a middleware that is used to protect a route by authorizing clients with a Bearer token.

This middleware will attach the claims into the echo.Context using JWT_CLAIMS.

func RequestId

func RequestId() echo.MiddlewareFunc

RequestId is a middleware that generates a random request id of length REQUEST_ID_LENGTH and attaches it to the request header.

func StructType

func StructType(structType reflect.Type) echo.MiddlewareFunc

StructType will register a struct type in the echo.Context for the incoming request. Optionally, provide a key for the struct type. Pass empty string to use default key "structype".

Types

This section is empty.

Jump to

Keyboard shortcuts

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