Version: v0.114.0 Latest Latest

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 2 Imported by: 114




This section is empty.


View Source
var ErrMethodNotAllowed error = &RouteError{"method not allowed"}

ErrMethodNotAllowed is returned when no method of the matched route matches

View Source
var ErrPathNotFound error = &RouteError{"no matching operation was found"}

ErrPathNotFound is returned when no route match is found


This section is empty.


type Route

type Route struct {
	Spec      *openapi3.T
	Server    *openapi3.Server
	Path      string
	PathItem  *openapi3.PathItem
	Method    string
	Operation *openapi3.Operation

Route describes the operation an http.Request can match

type RouteError

type RouteError struct {
	Reason string

RouteError describes Router errors

func (*RouteError) Error

func (e *RouteError) Error() string

type Router

type Router interface {
	// FindRoute matches an HTTP request with the operation it resolves to.
	// Hosts are matched from the OpenAPIv3 servers key.
	// If you experience ErrPathNotFound and have localhost hosts specified as your servers,
	// turning these server URLs as relative (leaving only the path) should resolve this.
	// See openapi3filter for example uses with request and response validation.
	FindRoute(req *http.Request) (route *Route, pathParams map[string]string, err error)

Router helps link http.Request.s and an OpenAPIv3 spec

Source Files


Path Synopsis
Package gorillamux implements a router.
Package gorillamux implements a router.
Package legacy implements a router.
Package legacy implements a router.
Package pathpattern implements path matching.
Package pathpattern implements path matching.

Jump to

Keyboard shortcuts

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