Documentation ¶
Index ¶
- Variables
- func URLParam(r *http.Request, key string) string
- type ChiRouter
- func (r *ChiRouter) Any(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) CONNECT(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) DELETE(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) GET(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) Group(path string) Router
- func (r *ChiRouter) HEAD(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) Handle(method string, path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) OPTIONS(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) PATCH(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) POST(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) PUT(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) RoutesCount() int
- func (r *ChiRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *ChiRouter) TRACE(path string, handler http.HandlerFunc, handlers ...Constructor)
- func (r *ChiRouter) Use(handlers ...Constructor) Router
- type Constructor
- type ListenPathMatcher
- type Options
- type Router
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = Options{ NotFoundHandler: http.NotFound, SafeAddRoutesWhileRunning: true, }
DefaultOptions are the default router options
Functions ¶
Types ¶
type ChiRouter ¶
type ChiRouter struct {
// contains filtered or unexported fields
}
ChiRouter is an adapter for chi router that implements the Router interface
func NewChiRouterWithOptions ¶
NewChiRouterWithOptions creates a new instance of ChiRouter with the provided options
func (*ChiRouter) Any ¶
func (r *ChiRouter) Any(path string, handler http.HandlerFunc, handlers ...Constructor)
Any register a path to all HTTP methods
func (*ChiRouter) CONNECT ¶
func (r *ChiRouter) CONNECT(path string, handler http.HandlerFunc, handlers ...Constructor)
CONNECT registers a HTTP CONNECT path
func (*ChiRouter) DELETE ¶
func (r *ChiRouter) DELETE(path string, handler http.HandlerFunc, handlers ...Constructor)
DELETE registers a HTTP DELETE path
func (*ChiRouter) GET ¶
func (r *ChiRouter) GET(path string, handler http.HandlerFunc, handlers ...Constructor)
GET registers a HTTP GET path
func (*ChiRouter) HEAD ¶
func (r *ChiRouter) HEAD(path string, handler http.HandlerFunc, handlers ...Constructor)
HEAD registers a HTTP HEAD path
func (*ChiRouter) Handle ¶
func (r *ChiRouter) Handle(method string, path string, handler http.HandlerFunc, handlers ...Constructor)
Handle registers a path, method and handlers to the router
func (*ChiRouter) OPTIONS ¶
func (r *ChiRouter) OPTIONS(path string, handler http.HandlerFunc, handlers ...Constructor)
OPTIONS registers a HTTP OPTIONS path
func (*ChiRouter) PATCH ¶
func (r *ChiRouter) PATCH(path string, handler http.HandlerFunc, handlers ...Constructor)
PATCH registers a HTTP PATCH path
func (*ChiRouter) POST ¶
func (r *ChiRouter) POST(path string, handler http.HandlerFunc, handlers ...Constructor)
POST registers a HTTP POST path
func (*ChiRouter) PUT ¶
func (r *ChiRouter) PUT(path string, handler http.HandlerFunc, handlers ...Constructor)
PUT registers a HTTP PUT path
func (*ChiRouter) RoutesCount ¶
RoutesCount returns number of routes registered
func (*ChiRouter) ServeHTTP ¶
func (r *ChiRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP server the HTTP requests
func (*ChiRouter) TRACE ¶
func (r *ChiRouter) TRACE(path string, handler http.HandlerFunc, handlers ...Constructor)
TRACE registers a HTTP TRACE path
func (*ChiRouter) Use ¶
func (r *ChiRouter) Use(handlers ...Constructor) Router
Use attaches a middleware to the router
type Constructor ¶
Constructor for a piece of middleware. Some middleware use this constructor out of the box, so in most cases you can just pass somepackage.New
type ListenPathMatcher ¶
type ListenPathMatcher struct {
// contains filtered or unexported fields
}
ListenPathMatcher is responsible for matchin a listen path to a set of rules
func NewListenPathMatcher ¶
func NewListenPathMatcher() *ListenPathMatcher
NewListenPathMatcher creates a new instance ListenPathMatcher
func (*ListenPathMatcher) Extract ¶
func (l *ListenPathMatcher) Extract(listenPath string) string
Extract takes the usable part of the listen path based on the provided rule
func (*ListenPathMatcher) Match ¶
func (l *ListenPathMatcher) Match(listenPath string) bool
Match verifies if a listen path matches the given rule
type Options ¶
type Options struct { NotFoundHandler http.HandlerFunc SafeAddRoutesWhileRunning bool }
Options are the HTTPTreeMuxRouter options
type Router ¶
type Router interface { ServeHTTP(w http.ResponseWriter, req *http.Request) Handle(method string, path string, handler http.HandlerFunc, handlers ...Constructor) Any(path string, handler http.HandlerFunc, handlers ...Constructor) GET(path string, handler http.HandlerFunc, handlers ...Constructor) POST(path string, handler http.HandlerFunc, handlers ...Constructor) PUT(path string, handler http.HandlerFunc, handlers ...Constructor) DELETE(path string, handler http.HandlerFunc, handlers ...Constructor) PATCH(path string, handler http.HandlerFunc, handlers ...Constructor) HEAD(path string, handler http.HandlerFunc, handlers ...Constructor) OPTIONS(path string, handler http.HandlerFunc, handlers ...Constructor) TRACE(path string, handler http.HandlerFunc, handlers ...Constructor) CONNECT(path string, handler http.HandlerFunc, handlers ...Constructor) Group(path string) Router Use(handlers ...Constructor) Router RoutesCount() int }
Router defines the basic methods for a router