middleware

package
v1.11.5 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EchoContextKey = "oapi-codegen/echo-context"
	UserDataKey    = "oapi-codegen/user-data"
)

Variables

This section is empty.

Functions

func GetEchoContext

func GetEchoContext(c context.Context) echo.Context

Helper function to get the echo context from within requests. It returns nil if not found or wrong type.

func GetUserData

func GetUserData(c context.Context) interface{}

func OapiRequestValidator

func OapiRequestValidator(swagger *openapi3.T) echo.MiddlewareFunc

Create a validator from a swagger object.

func OapiRequestValidatorWithOptions

func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) echo.MiddlewareFunc

OapiRequestValidatorWithOptions creates a validator from a swagger object, with validation options

func OapiValidatorFromYamlFile

func OapiValidatorFromYamlFile(path string) (echo.MiddlewareFunc, error)

Create validator middleware from a YAML file path

func ValidateRequestFromContext

func ValidateRequestFromContext(ctx echo.Context, router routers.Router, options *Options) *echo.HTTPError

ValidateRequestFromContext is called from the middleware above and actually does the work of validating a request.

Types

type ErrorHandler

type ErrorHandler func(c echo.Context, err *echo.HTTPError) error

ErrorHandler is called when there is an error in validation

type Options

type Options struct {
	ErrorHandler ErrorHandler
	Options      openapi3filter.Options
	ParamDecoder openapi3filter.ContentParameterDecoder
	UserData     interface{}
	Skipper      echomiddleware.Skipper
}

Options to customize request validation. These are passed through to openapi3filter.

Jump to

Keyboard shortcuts

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