Documentation ¶
Index ¶
- func MethodNotAllowed(remainingPath string, resp http.ResponseWriter, req *http.Request) bool
- func NewLoggingHandler(delegate http.Handler, logger logging.Logger) http.Handler
- func RouteHandlerFunc(matcher Matcher) func(http.ResponseWriter, *http.Request)
- type LoggingHandler
- type Matcher
- func DELETE(handler http.Handler) Matcher
- func DELETEFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
- func End(subMatcher Matcher) Matcher
- func EndSeq(subMatchers ...Matcher) Matcher
- func GET(handler http.Handler) Matcher
- func GETFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
- func IntPart(matcherForPart func(int) Matcher) Matcher
- func Method(method string, handler http.Handler) Matcher
- func PATCH(handler http.Handler) Matcher
- func PATCHFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
- func POST(handler http.Handler) Matcher
- func POSTFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
- func PUT(handler http.Handler) Matcher
- func PUTFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
- func Prefix(prefix string, subMatcher Matcher) Matcher
- func PrefixSeq(prefix string, subMatchers ...Matcher) Matcher
- func Sequence(matchers ...Matcher) Matcher
- func StringPart(matcherForPart func(string) Matcher) Matcher
- type RouteHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MethodNotAllowed ¶
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 ¶
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 ¶
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 DELETEFunc ¶
func DELETEFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
DELETEFunc create a matcher that delegates to a function on HTTP DELETE
func GETFunc ¶
func GETFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
GETFunc create a matcher that delegates to a function on HTTP GET
func PATCHFunc ¶
func PATCHFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
PATCHFunc create a matcher that delegates to a function on HTTP PATCH
func POSTFunc ¶
func POSTFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
POSTFunc create a matcher that delegates to a function on HTTP POST
func PUTFunc ¶
func PUTFunc(handler func(http.ResponseWriter, *http.Request)) Matcher
PUTFunc create a matcher that delegates to a function on HTTP PUT
func StringPart ¶
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)