middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddStoreIDToCtx

func AddStoreIDToCtx(next http.Handler) http.Handler

Extract StoreID (internal_id) from CustomClaims and add to request context.

Must only be used after the EnsureValidToken method on the middleware chain

func EnsureValidToken

func EnsureValidToken(logger metrics.Logger) func(next http.Handler) http.Handler

EnsureValidToken is a middleware that will check the validity of our JWT.

func NewStructuredLogger

func NewStructuredLogger(handler *metrics.Logger) func(next http.Handler) http.Handler

Types

type CustomClaims

type CustomClaims struct {
	InternalID string `json:"internal_id,omitempty"`
	Scope      string `json:"scope"`
}

CustomClaims contains custom data we want from the token.

func (CustomClaims) HasScope

func (c CustomClaims) HasScope(expectedScope string) bool

HasScope checks whether our claims have a specific scope.

func (CustomClaims) Validate

func (c CustomClaims) Validate(ctx context.Context) error

Validate does nothing for this example, but we need it to satisfy validator.CustomClaims interface.

type CustomLogger

type CustomLogger struct {
	// contains filtered or unexported fields
}

func (*CustomLogger) NewLogEntry

func (cl *CustomLogger) NewLogEntry(r *http.Request) middleware.LogEntry

Jump to

Keyboard shortcuts

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