middleware

package
v1.16.3 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 64

Documentation

Overview

Package middleware implements middleware function for go-chi or net/http, which validates incoming HTTP requests to make sure that they conform to the given OAPI 3.0 specification. When OAPI validation fails on the request, we return an HTTP/400.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OapiRequestValidator deprecated

func OapiRequestValidator(swagger *openapi3.T) func(next http.Handler) http.Handler

OapiRequestValidator Creates middleware to validate request by swagger spec. This middleware is good for net/http either since go-chi is 100% compatible with net/http.

Deprecated: This has been replaced by https://pkg.go.dev/github.com/oapi-codegen/nethttp-middleware#OapiRequestValidator

func OapiRequestValidatorWithOptions deprecated

func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) func(next http.Handler) http.Handler

OapiRequestValidatorWithOptions Creates middleware to validate request by swagger spec. This middleware is good for net/http either since go-chi is 100% compatible with net/http.

Deprecated: This has been replaced by https://pkg.go.dev/github.com/oapi-codegen/nethttp-middleware#OapiRequestValidatorWithOptions

Types

type ErrorHandler deprecated added in v1.11.0

type ErrorHandler func(w http.ResponseWriter, message string, statusCode int)

ErrorHandler is called when there is an error in validation

Deprecated: This has been replaced by https://pkg.go.dev/github.com/oapi-codegen/nethttp-middleware#ErrorHandler

type MultiErrorHandler deprecated added in v1.12.0

type MultiErrorHandler func(openapi3.MultiError) (int, error)

MultiErrorHandler is called when oapi returns a MultiError type

Deprecated: This has been replaced by https://pkg.go.dev/github.com/oapi-codegen/nethttp-middleware#MultiErrorHandler

type Options deprecated

type Options struct {
	Options           openapi3filter.Options
	ErrorHandler      ErrorHandler
	MultiErrorHandler MultiErrorHandler
	// SilenceServersWarning allows silencing a warning for https://github.com/deepmap/oapi-codegen/issues/882 that reports when an OpenAPI spec has `spec.Servers != nil`
	SilenceServersWarning bool
}

Options to customize request validation, openapi3filter specified options will be passed through.

Deprecated: This has been replaced by https://pkg.go.dev/github.com/oapi-codegen/nethttp-middleware#Options

Jump to

Keyboard shortcuts

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