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 ¶
- func NewRouter(doc *openapi3.Swagger) (routers.Router, error)
- type Router
- func (router *Router) AddRoute(route *routers.Route) error
- func (router *Router) FindRoute(req *http.Request) (*routers.Route, map[string]string, error)
- type Routers
Functions ¶
func NewRouter ¶
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 ¶
AddRoute adds a route in the router.
func (*Router) FindRoute ¶
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 ¶
Directories ¶
Path | Synopsis |
---|---|
routers/legacy/pathpattern | Package pathpattern implements path matching. |
- Version
- v0.52.0
- Published
- Mar 20, 2021
- Platform
- windows/amd64
- Imports
- 8 packages
- Last checked
- 7 minutes ago –
Tools for package owners.