middleware

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 10 Imported by: 1

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 OAPIValidator

func OAPIValidator(swagger *openapi3.T, opts ...func(*Options)) func(next http.Handler) http.Handler

func WithErrContentType

func WithErrContentType(contentType ErrRespContentType) func(*Options)

WithErrContentType sets the content type of the error response

func WithOptions

func WithOptions(opt *openapi3filter.Options) func(*Options)

WithOptions sets the openapi3filter options for the middleware

Types

type ErrRespContentType

type ErrRespContentType string

ErrRespContentType represents the support content-types for the response when a validation error occurs

const (
	ErrRespContentTypePlain ErrRespContentType = "text/plain"
	ErrRespContentTypeJSON  ErrRespContentType = "application/json"
	ErrRespContentTypeXML   ErrRespContentType = "application/xml"
)

Consts to expose supported Error Response Content-Types

type Options

type Options struct {
	Options *openapi3filter.Options
	ErrRespContentType
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

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