package gorillamux

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

Package gorillamux implements a router.

It differs from the legacy router: * it provides somewhat granular errors: "path not found", "method not allowed". * it handles 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 gorilla/mux router. Assumes spec is .Validate()d TODO: Handle/HandlerFunc + ServeHTTP (When there is a match, the route variables can be retrieved calling mux.Vars(request))

Types

type Router

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

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

func (*Router) FindRoute

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

FindRoute extracts the route and parameters of an http.Request

Source Files

router.go

Version
v0.56.0
Published
Apr 23, 2021
Platform
windows/amd64
Imports
7 packages
Last checked
1 hour ago

Tools for package owners.