Documentation
¶
Index ¶
- type MiddlewareFunc
- type Params
- type Router
- func (r *Router) DELETE(path string, handler http.HandlerFunc) *Router
- func (r *Router) EnableMethodNotAllowedCheck(enabled bool)
- func (r *Router) GET(path string, handler http.HandlerFunc) *Router
- func (r *Router) Group(prefix string, middleware ...MiddlewareFunc) *Router
- func (r *Router) HEAD(path string, handler http.HandlerFunc) *Router
- func (r *Router) MethodNotAllowed(handler http.HandlerFunc)
- func (r *Router) NotFound(handler http.HandlerFunc)
- func (r *Router) OPTIONS(path string, handler http.HandlerFunc) *Router
- func (r *Router) PATCH(path string, handler http.HandlerFunc) *Router
- func (r *Router) POST(path string, handler http.HandlerFunc) *Router
- func (r *Router) PUT(path string, handler http.HandlerFunc) *Router
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Use(middleware ...MiddlewareFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MiddlewareFunc ¶ added in v1.1.0
MiddlewareFunc represents a middleware function
type Params ¶ added in v1.1.0
type Params struct {
// contains filtered or unexported fields
}
Params holds route parameters extracted from the URL Optimized to reduce allocations compared to map[string]string
func ParamsFromContext ¶ added in v1.1.0
ParamsFromContext extracts route parameters from the request context
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, handler http.HandlerFunc) *Router
DELETE adds a DELETE route
func (*Router) EnableMethodNotAllowedCheck ¶ added in v1.2.0
EnableMethodNotAllowedCheck toggles costly cross-method lookup on 404
func (*Router) GET ¶
func (r *Router) GET(path string, handler http.HandlerFunc) *Router
GET adds a GET route
func (*Router) Group ¶ added in v1.1.0
func (r *Router) Group(prefix string, middleware ...MiddlewareFunc) *Router
Group creates a new route group with a prefix and optional middleware
func (*Router) HEAD ¶
func (r *Router) HEAD(path string, handler http.HandlerFunc) *Router
HEAD adds a HEAD route
func (*Router) MethodNotAllowed ¶ added in v1.1.0
func (r *Router) MethodNotAllowed(handler http.HandlerFunc)
MethodNotAllowed sets a custom 405 handler
func (*Router) NotFound ¶ added in v1.1.0
func (r *Router) NotFound(handler http.HandlerFunc)
NotFound sets a custom 404 handler
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(path string, handler http.HandlerFunc) *Router
OPTIONS adds an OPTIONS route
func (*Router) PATCH ¶
func (r *Router) PATCH(path string, handler http.HandlerFunc) *Router
PATCH adds a PATCH route
func (*Router) POST ¶
func (r *Router) POST(path string, handler http.HandlerFunc) *Router
POST adds a POST route
func (*Router) PUT ¶
func (r *Router) PUT(path string, handler http.HandlerFunc) *Router
PUT adds a PUT route
func (*Router) ServeHTTP ¶
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implements the http.Handler interface
func (*Router) Use ¶ added in v1.1.0
func (r *Router) Use(middleware ...MiddlewareFunc)
Use adds global middleware to the router