Documentation ¶
Index ¶
- type Middleware
- type Router
- func (r *Router) Connect(path string, hf http.HandlerFunc)
- func (r *Router) Delete(path string, hf http.HandlerFunc)
- func (r *Router) Get(path string, hf http.HandlerFunc)
- func (r *Router) Handle(path string, handler http.Handler)
- func (r *Router) HandleFunc(path string, hf http.HandlerFunc)
- func (r *Router) HandleMethod(method, path string, handler http.Handler)
- func (r *Router) Handler(req *http.Request) (h http.Handler, pattern string)
- func (r *Router) Head(path string, hf http.HandlerFunc)
- func (r *Router) Mount(pathPrefix string, h http.Handler)
- func (r *Router) Options(path string, hf http.HandlerFunc)
- func (r *Router) Patch(path string, hf http.HandlerFunc)
- func (r *Router) Post(path string, hf http.HandlerFunc)
- func (r *Router) Put(path string, hf http.HandlerFunc)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Trace(path string, hf http.HandlerFunc)
- func (r *Router) Use(mws ...Middleware)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
Middleware describes the signature of an http handler middleware.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router wraps the net/http ServeMux with helpre methods.
func (*Router) Connect ¶
func (r *Router) Connect(path string, hf http.HandlerFunc)
Connect register a handler func under the given path for the http method CONNECT.
func (*Router) Delete ¶
func (r *Router) Delete(path string, hf http.HandlerFunc)
Delete register a handler func under the given path for the http method DELETE.
func (*Router) Get ¶
func (r *Router) Get(path string, hf http.HandlerFunc)
Get register a handler func under the given path for the http method GET.
func (*Router) HandleFunc ¶ added in v0.0.1
func (r *Router) HandleFunc(path string, hf http.HandlerFunc)
Handle registers the given handler to the given path.
func (*Router) HandleMethod ¶ added in v0.0.1
HandleMethod registers the given handler to the given method and path.
func (*Router) Handler ¶
Handler returns the handler to use for the given request, consulting r.Method, r.Host, and r.URL.Path. It always returns a non-nil handler. If the path is not in its canonical form, the handler will be an internally-generated handler that redirects to the canonical path. If the host contains a port, it is ignored when matching handlers.
The path and host are used unchanged for CONNECT requests.
Handler also returns the registered pattern that matches the request or, in the case of internally-generated redirects, the path that will match after following the redirect.
If there is no registered handler that applies to the request, Handler returns a “page not found” handler and an empty pattern.
func (*Router) Head ¶
func (r *Router) Head(path string, hf http.HandlerFunc)
Head register a handler func under the given path for the http method HEAD.
func (*Router) Options ¶
func (r *Router) Options(path string, hf http.HandlerFunc)
Options register a handler func under the given path for the http method OPTIONS.
func (*Router) Patch ¶
func (r *Router) Patch(path string, hf http.HandlerFunc)
Patch register a handler func under the given path for the http method PATCH.
func (*Router) Post ¶
func (r *Router) Post(path string, hf http.HandlerFunc)
Post register a handler func under the given path for the http method POST.
func (*Router) Put ¶
func (r *Router) Put(path string, hf http.HandlerFunc)
Put register a handler func under the given path for the http method PUT.
func (*Router) Trace ¶
func (r *Router) Trace(path string, hf http.HandlerFunc)
Trace register a handler func under the given path for the http method TRACE.
func (*Router) Use ¶
func (r *Router) Use(mws ...Middleware)
Use applies the given middleware in the given order