routing

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MethodNotAllowed

func MethodNotAllowed(remainingPath string, resp http.ResponseWriter, req *http.Request) bool

MethodNotAllowed creates a matcher that matches everything and always replies with a 405. Useful at the end of a sequence of method matchers.

func NewLoggingHandler

func NewLoggingHandler(delegate http.Handler, logger logging.Logger) http.Handler

NewLoggingHandler create a new LoggingHandler.

func RouteHandlerFunc

func RouteHandlerFunc(matcher Matcher) func(http.ResponseWriter, *http.Request)

Types

type LoggingHandler

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

LoggingHandler is a http.Handler that logs and delegates all requests.

func (*LoggingHandler) ServeHTTP

func (l *LoggingHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type Matcher

type Matcher func(remainingPath string, resp http.ResponseWriter, req *http.Request) bool

Matcher matches a HTTP request. If the matcher returns true, the HTTP request is considered to be handled and no other matcher should be tried.

func DELETE

func DELETE(handler http.Handler) Matcher

DELETE creates a matcher that matches HTTP DELETE

func DELETEFunc

func DELETEFunc(handler func(http.ResponseWriter, *http.Request)) Matcher

DELETEFunc create a matcher that delegates to a function on HTTP DELETE

func End

func End(subMatcher Matcher) Matcher

func EndSeq

func EndSeq(subMatchers ...Matcher) Matcher

func GET

func GET(handler http.Handler) Matcher

GET creates a matcher that matches HTTP GET

func GETFunc

func GETFunc(handler func(http.ResponseWriter, *http.Request)) Matcher

GETFunc create a matcher that delegates to a function on HTTP GET

func IntPart

func IntPart(matcherForPart func(int) Matcher) Matcher

func Method

func Method(method string, handler http.Handler) Matcher

Method create a matcher that matches a specific HTTP method

func PATCH

func PATCH(handler http.Handler) Matcher

PATCH creates a matcher that matches HTTP PATCH

func PATCHFunc

func PATCHFunc(handler func(http.ResponseWriter, *http.Request)) Matcher

PATCHFunc create a matcher that delegates to a function on HTTP PATCH

func POST

func POST(handler http.Handler) Matcher

POST creates a matcher that matches HTTP POST

func POSTFunc

func POSTFunc(handler func(http.ResponseWriter, *http.Request)) Matcher

POSTFunc create a matcher that delegates to a function on HTTP POST

func PUT

func PUT(handler http.Handler) Matcher

PUT creates a matcher that matches HTTP PUT

func PUTFunc

func PUTFunc(handler func(http.ResponseWriter, *http.Request)) Matcher

PUTFunc create a matcher that delegates to a function on HTTP PUT

func Prefix

func Prefix(prefix string, subMatcher Matcher) Matcher

func PrefixSeq

func PrefixSeq(prefix string, subMatchers ...Matcher) Matcher

func Sequence

func Sequence(matchers ...Matcher) Matcher

func StringPart

func StringPart(matcherForPart func(string) Matcher) Matcher

type RouteHandler

type RouteHandler struct {
	Matcher Matcher
}

RouteHandler is a http.Handler delegating the request to a Matcher.

func NewRouteHandler

func NewRouteHandler(matchers ...Matcher) *RouteHandler

NewRouteHandler creates a RouteHandler for a sequence of Matcher.

func (*RouteHandler) ServeHTTP

func (r *RouteHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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