package legacy

import "github.com/getkin/kin-openapi/routers/legacy"

Package legacy implements a router.

It differs from the gorilla/mux router: * it provides granular errors: "path not found", "method not allowed", "variable missing from path" * it does not handle matching routes with extensions (e.g. /books/{id}.json) * it handles path patterns with a different syntax (e.g. /params/{x}/{y}/{z.*})

Index

Functions

func NewRouter

func NewRouter(doc *openapi3.Swagger) (routers.Router, error)

NewRouter creates a new router.

If the given Swagger has servers, router will use them. All operations of the Swagger will be added to the router.

Types

type Router

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

Router maps a HTTP request to an OpenAPI operation.

func (*Router) AddRoute

func (router *Router) AddRoute(route *routers.Route) error

AddRoute adds a route in the router.

func (*Router) FindRoute

func (router *Router) FindRoute(req *http.Request) (*routers.Route, map[string]string, error)

FindRoute extracts the route and parameters of an http.Request

type Routers

type Routers []*Router

Routers maps a HTTP request to a Router.

func (Routers) FindRoute

func (rs Routers) FindRoute(req *http.Request) (routers.Router, *routers.Route, map[string]string, error)

FindRoute extracts the route and parameters of an http.Request

Source Files

router.go

Directories

PathSynopsis
routers/legacy/pathpatternPackage pathpattern implements path matching.
Version
v0.57.0
Published
Apr 23, 2021
Platform
windows/amd64
Imports
8 packages
Last checked
1 hour ago

Tools for package owners.