Documentation ¶
Index ¶
Constants ¶
const ( SLASH = '/' COLON = ':' STAR = '*' )
const MAXPARAMS = 16
Variables ¶
var ParamsTag = paramsKey{}
Functions ¶
func WriteHeader ¶ added in v0.2.3
func WriteHeader(w http.ResponseWriter, status int) (int, error)
WriteHeader is just for convenience
Types ¶
type AdapterResponseWriter ¶
type AdapterResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func (*AdapterResponseWriter) Status ¶
func (w *AdapterResponseWriter) Status() int
func (*AdapterResponseWriter) WriteHeader ¶
func (w *AdapterResponseWriter) WriteHeader(code int)
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
type Handler ¶
Handler is the signature of a Heligo handler. It gets a standard context taken from http.Request, a http.RequestWriter and a heligo.Request. You should return the HTTP status code and a potential error (or nil).
func Adapt ¶
Adapt adapts a standard http.Handler to be used as a Heligo handler. In the standard handler one can retrieve parameters from the context, using ParamsFromContext.
func AdaptFunc ¶ added in v0.2.0
func AdaptFunc(hf http.HandlerFunc) Handler
Adapt adapts a standard http.Handler to be used as a Heligo handler.
type Middleware ¶
Middleware is the signature of a Heligo middleware.
func AdaptAsMiddleware ¶ added in v0.1.2
func AdaptAsMiddleware(h http.Handler) Middleware
AdaptAsMiddleware adapts a standard http.Handler to be used as a Heligo middleware. Note the this is less flexible than the previous AdaptMiddleware, as it doesn't not allow to break the middleware chain except in the case of errors and calls the next handler only at the end.
func AdaptFuncAsMiddleware ¶ added in v0.2.0
func AdaptFuncAsMiddleware(hf http.HandlerFunc) Middleware
AdaptFuncAsMiddleware adapts a standard http.HandlerFunc to be used as a Heligo middleware.
func AdaptMiddleware ¶ added in v0.1.2
func AdaptMiddleware(m func(http.Handler) http.Handler) Middleware
AdaptMiddleware adapts a standard middleware (func(http.Handler) http.Handler) to be used as a Heligo middleware
type Param ¶
func ParamsFromContext ¶
ParamsFromContext gets the route parameters from the context
type Request ¶
Request embeds the standard http.Request and the URL parameters in a compressed format
func (*Request) Param ¶
Param returns a URL parameter by name. It returns an empty string if the requested parameter is not found.
func (*Request) ParamByPos ¶
ParamByPos gets a URL parameter by position in the URL (0-based)
type Router ¶
func (*Router) Group ¶
func (router *Router) Group(path string, middlewares ...Middleware) *Group
Group creates a new group of handlers, with common middlewares
func (*Router) ServeHTTP ¶
func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP complies with the standard http.Handler interface
func (*Router) Use ¶
func (router *Router) Use(middlewares ...Middleware)
Use registers a global middleware. The middlewares are called in the order they are registered.