handler

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBeforeFunc

func DefaultBeforeFunc(ctx context.Context, req *middleware.Request) error

func DefaultErrorHandler

func DefaultErrorHandler(ctx context.Context, req *middleware.Request, err error) error

func DefaultSkipper

func DefaultSkipper(ctx context.Context, req *middleware.Request) bool

func DefaultSuccessFunc

func DefaultSuccessFunc(ctx context.Context, req *middleware.Request) error

func NewShim

func NewShim(opts ...ShimOpt) *shim

func WithExtractFunc

func WithExtractFunc(f func(ctx context.Context, req *middleware.Request) (context.Context, error)) jwtHandlerOpt

func WithExtractor

func WithExtractor(extractor extractor.HeaderExtractor) jwtHandlerOpt

func WithJwtMapClaimsParser

func WithJwtMapClaimsParser(signingKey any) jwtHandlerOpt

func WithParseFunc

func WithParseFunc(f func(ctx context.Context) (any, error)) jwtHandlerOpt

func WithParser

func WithParser(parser parser.JwtParser) jwtHandlerOpt

Types

type JWTHandler

type JWTHandler struct {
	Capacity         int
	HeaderExtractors []extractor.HeaderExtractor
	Parser           parser.JwtParser
	ExtractFunc      func(ctx context.Context, req *middleware.Request) (context.Context, error)
	ParseFunc        func(ctx context.Context) (any, error)
	Shim
}

func NewJWTHandler

func NewJWTHandler(shim Shim, opts ...jwtHandlerOpt) *JWTHandler

func (*JWTHandler) Extract

func (h *JWTHandler) Extract(ctx context.Context, req *middleware.Request) (context.Context, error)

func (*JWTHandler) Parse

func (h *JWTHandler) Parse(ctx context.Context) (any, error)

type Shim

type Shim interface {
	Skip(ctx context.Context, req *middleware.Request) bool
	Before(ctx context.Context, req *middleware.Request) error
	Success(ctx context.Context, req *middleware.Request) error
	HandleError(ctx context.Context, req *middleware.Request, err error) error
}

type ShimOpt

type ShimOpt func(*shim)

func WithBeforeFunc

func WithBeforeFunc(beforeFunc func(ctx context.Context, req *middleware.Request) error) ShimOpt

func WithErrorHandler

func WithErrorHandler(errorHandler func(ctx context.Context, req *middleware.Request, err error) error) ShimOpt

func WithSkipper

func WithSkipper(skipper func(ctx context.Context, req *middleware.Request) bool) ShimOpt

func WithSuccessFunc

func WithSuccessFunc(successFunc func(ctx context.Context, req *middleware.Request) error) ShimOpt

Jump to

Keyboard shortcuts

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