legacy

package
v0.55.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MIT Imports: 8 Imported by: 36

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

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

Directories

Path Synopsis
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