middleware

package
v0.3.61 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger() func(next http.Handler) http.Handler

Logger attaches logging context to the request.

func OpenAPIValidatorMiddlewareFactory

func OpenAPIValidatorMiddlewareFactory(authorizer *Authorizer, openapi *OpenAPI) func(http.Handler) http.Handler

OpenAPIValidatorMiddlewareFactory returns a function that generates per-request middleware functions.

func Timeout

func Timeout(timeout time.Duration) func(http.Handler) http.Handler

Timeout adds a timeout to requests.

Types

type Authorizer

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

Authorizer provides OpenAPI based authorization middleware.

func NewAuthorizer

func NewAuthorizer(issuer *jose.JWTIssuer) *Authorizer

NewAuthorizer returns a new authorizer with required parameters.

type LoggingSpanProcessor

type LoggingSpanProcessor struct{}

LoggingSpanProcessor is a OpenTelemetry span processor that logs to standard out in whatever format is defined by the logger.

func (*LoggingSpanProcessor) ForceFlush

func (*LoggingSpanProcessor) ForceFlush(ctx context.Context) error

func (*LoggingSpanProcessor) OnEnd

func (*LoggingSpanProcessor) OnStart

func (*LoggingSpanProcessor) Shutdown

func (*LoggingSpanProcessor) Shutdown(ctx context.Context) error

type OpenAPI

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

OpenAPI abstracts schema access and validation.

func NewOpenAPI

func NewOpenAPI() (*OpenAPI, error)

NewOpenRpi extracts the swagger document. NOTE: this is surprisingly slow, make sure you cache it and reuse it.

type OpenAPIValidator

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

OpenAPIValidator provides OpenAPI validation of request and response codes, media, and schema validation of payloads to ensure we are meeting the specification.

func NewOpenAPIValidator

func NewOpenAPIValidator(authorizer *Authorizer, next http.Handler, openapi *OpenAPI) *OpenAPIValidator

NewOpenAPIValidator returns an initialized validator middleware.

func (*OpenAPIValidator) ServeHTTP

func (v *OpenAPIValidator) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

Jump to

Keyboard shortcuts

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