Documentation ¶
Overview ¶
Package air provides a http router which wraps `github.com/julienschmidt/httprouter` to support `http.Handler` with URL params via `Context` package.
Index ¶
- Variables
- func Compose(h http.Handler, mws ...Middleware) http.Handler
- func Param(r *http.Request, key string) string
- type H
- type Middleware
- type Router
- func (r *Router) DELETE(path string, h http.Handler)
- func (r *Router) GET(path string, h http.Handler)
- func (r *Router) HEAD(path string, h http.Handler)
- func (r *Router) Handle(method, path string, h http.Handler)
- func (r *Router) OPTIONS(path string, h http.Handler)
- func (r *Router) PATCH(path string, h http.Handler)
- func (r *Router) POST(path string, h http.Handler)
- func (r *Router) PUT(path string, h http.Handler)
Constants ¶
This section is empty.
Variables ¶
View Source
var ParamsKey = &contextKey{"key of params"}
ParamsKey is the key to get URL params from a Context.
Functions ¶
Types ¶
type H ¶
type H func(http.ResponseWriter, *http.Request)
H is a copy of http.HandlerFunc. It makes easy to cast handler functions to http.Handler.
type Middleware ¶
Middleware is an alias of `func(http.Handler) http.Handler`. These functions wrap a http.Handler with some additonal features.
func middleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // some additional features... next(w, r) }) }
func Composer ¶
func Composer(mws ...Middleware) Middleware
Composer returns a new middleware which is composed of passed middlewares. It is just a partially applied function of `Compose` .
type Router ¶
type Router struct{ *httprouter.Router }
Router is a simple URL router which acts as a http.Handler.
Click to show internal directories.
Click to hide internal directories.