Documentation
¶
Overview ¶
Package httpx is the routing layer.
It is a thin shell over net/http: Middleware is the standard func(http.Handler) http.Handler, so every middleware written for the Go ecosystem works here unchanged.
Index ¶
- func Chain(h http.Handler, mws ...Middleware) http.Handler
- type Middleware
- type Route
- type Router
- func (r *Router) Delete(pattern string, h http.HandlerFunc, mws ...Middleware)
- func (r *Router) ForModule(name string) *Router
- func (r *Router) Get(pattern string, h http.HandlerFunc, mws ...Middleware)
- func (r *Router) Group(prefix string, mws ...Middleware) *Router
- func (r *Router) Patch(pattern string, h http.HandlerFunc, mws ...Middleware)
- func (r *Router) Post(pattern string, h http.HandlerFunc, mws ...Middleware)
- func (r *Router) Put(pattern string, h http.HandlerFunc, mws ...Middleware)
- func (r *Router) Routes() []Route
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Middleware ¶
Middleware is the standard net/http signature. We do not invent our own type: that is what keeps the whole Go ecosystem compatible with the framework.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a thin shell over http.ServeMux, which since Go 1.22 already handles methods and path parameters. It exists for groups, per-group middleware and route metadata -- the metadata is what lets the CLI generate typed URL helpers and what the error page uses to show the matched route.
func (*Router) Delete ¶
func (r *Router) Delete(pattern string, h http.HandlerFunc, mws ...Middleware)
Delete registers a DELETE route.
func (*Router) ForModule ¶
ForModule returns a sub-router that tags its routes with the module name, so `aru routes` can group them. The Kernel calls it for each module.
func (*Router) Get ¶
func (r *Router) Get(pattern string, h http.HandlerFunc, mws ...Middleware)
Get registers a GET route.
func (*Router) Group ¶
func (r *Router) Group(prefix string, mws ...Middleware) *Router
Group returns a sub-router with the prefix appended and the middleware inherited. The route table is shared with the parent.
func (*Router) Patch ¶
func (r *Router) Patch(pattern string, h http.HandlerFunc, mws ...Middleware)
Patch registers a PATCH route.
func (*Router) Post ¶
func (r *Router) Post(pattern string, h http.HandlerFunc, mws ...Middleware)
Post registers a POST route.
func (*Router) Put ¶
func (r *Router) Put(pattern string, h http.HandlerFunc, mws ...Middleware)
Put registers a PUT route.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package middleware holds the mandatory request pipeline.
|
Package middleware holds the mandatory request pipeline. |