Documentation ¶
Index ¶
- func GetAllParams(r *http.Request) paramsMapType
- func GetParam(r *http.Request, key string) string
- type Node
- type Router
- func (router *Router) DELETE(path string, handle http.HandlerFunc)
- func (router *Router) GET(path string, handle http.HandlerFunc)
- func (router *Router) Group(prefix string) *Router
- func (router *Router) Handle(method string, path string, handle http.HandlerFunc)
- func (router *Router) HandleNotFound(w http.ResponseWriter, r *http.Request, middleware []middlewareType)
- func (router *Router) Match(requestUrl string, path string) bool
- func (router *Router) NotFoundFunc(handler http.HandlerFunc)
- func (router *Router) PATCH(path string, handle http.HandlerFunc)
- func (router *Router) POST(path string, handle http.HandlerFunc)
- func (router *Router) PUT(path string, handle http.HandlerFunc)
- func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (router *Router) Use(middleware ...middlewareType)
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAllParams ¶
GetAllParams return all route params stored in r.
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node records any URL params, and executes an end handler.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a simple HTTP route multiplexer that parses a request path, records any URL params, and executes an end handler.
func New ¶
func New() *Router
New returns a newly initialized Router object that implements the Router
func (*Router) DELETE ¶
func (router *Router) DELETE(path string, handle http.HandlerFunc)
DELETE adds the route `path` that matches a DELETE http method to execute the `handle` http.HandlerFunc.
func (*Router) GET ¶
func (router *Router) GET(path string, handle http.HandlerFunc)
GET adds the route `path` that matches a GET http method to execute the `handle` http.HandlerFunc.
func (*Router) Group ¶
Group define routes groups If there is a path prefix that use `prefix`
func (*Router) Handle ¶
func (router *Router) Handle(method string, path string, handle http.HandlerFunc)
Handle registers a new request handle with the given path and method.
func (*Router) HandleNotFound ¶
func (router *Router) HandleNotFound(w http.ResponseWriter, r *http.Request, middleware []middlewareType)
HandleNotFound registers a handler when the request route is not found
func (*Router) Match ¶
Match check if the request match the route Pattern
func (*Router) NotFoundFunc ¶
func (router *Router) NotFoundFunc(handler http.HandlerFunc)
NotFoundFunc registers a handler when the request route is not found
func (*Router) PATCH ¶
func (router *Router) PATCH(path string, handle http.HandlerFunc)
PATCH adds the route `path` that matches a PATCH http method to execute the `handle` http.HandlerFunc.
func (*Router) POST ¶
func (router *Router) POST(path string, handle http.HandlerFunc)
POST adds the route `path` that matches a POST http method to execute the `handle` http.HandlerFunc.
func (*Router) PUT ¶
func (router *Router) PUT(path string, handle http.HandlerFunc)
PUT adds the route `path` that matches a PUT http method to execute the `handle` http.HandlerFunc.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree records node
func NewTree ¶
func NewTree() *Tree
NewTree returns a newly initialized Tree object that implements the Tree
func (*Tree) Add ¶
func (tree *Tree) Add(pattern string, handle http.HandlerFunc, middleware ...middlewareType)
Add use `pattern` 、handle、middleware stack as node register to tree