Documentation ¶
Index ¶
- func NewMatchContext(cxt context.Context, match *Match) context.Context
- type Attributes
- type Context
- type Handler
- type Match
- type Matcher
- type Middle
- type MiddleFunc
- type Middles
- type Request
- type Responder
- type ResponderFunc
- type Response
- func (r *Response) ReadEntity() ([]byte, error)
- func (r *Response) SetBytes(t string, d []byte) (*Response, error)
- func (r *Response) SetEntity(e entity.Entity) (*Response, error)
- func (r *Response) SetHeader(k, v string) *Response
- func (r *Response) SetJSON(d interface{}) (*Response, error)
- func (r *Response) SetString(t, d string) (*Response, error)
- type Route
- func (r *Route) Attr(k string, v interface{}) *Route
- func (r *Route) Attrs(attrs map[string]interface{}) *Route
- func (r *Route) Context(match *Match) Context
- func (r *Route) Describe(verbose bool) string
- func (r *Route) Handle(req *Request, cxt Context) (*Response, error)
- func (r *Route) Match(m Matcher) *Route
- func (r *Route) Matches(req *Request, state *matchState) *Match
- func (r *Route) Methods(m ...string) *Route
- func (r *Route) Param(k, v string) *Route
- func (r *Route) Params(p url.Values) *Route
- func (r *Route) Paths(s ...string) *Route
- func (r *Route) String() string
- func (r *Route) Use(m ...Middle) *Route
- func (r *Route) With(opts ...RouteOption) *Route
- type RouteOption
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attributes ¶
type Attributes map[string]interface{}
Request attributes
func (Attributes) Copy ¶
func (a Attributes) Copy() Attributes
func (Attributes) String ¶
func (a Attributes) String() string
type MiddleFunc ¶
Middle function wrapper
func (MiddleFunc) Wrap ¶
func (m MiddleFunc) Wrap(h Handler) Handler
MiddleFunc conforms to Middle by calling itself with the handler
type Request ¶
func (*Request) OriginAddr ¶
OriginAddr tries to identify the best address possible representing the origination of the request.
When available it prefers the `X-Forwarded-For` header, which is widely used by middleware infrastructure for this purpose. Failing that, the http.Request.RemotAddr is used with the port portion of the value removed.
If none of the above is available and empty string is returned.
type Responder ¶ added in v2.3.0
type Responder interface {
Response() *Response
}
A responder is anything that can be converted to a response. Usually this is something like an error or a static, default response at the end a chain of processing.
type ResponderFunc ¶ added in v2.3.0
type ResponderFunc func() *Response
func (ResponderFunc) Response ¶ added in v2.3.0
func (r ResponderFunc) Response() *Response
type Response ¶
type Response struct { Status int Header http.Header Entity io.ReadCloser }
func NewResponse ¶
func (*Response) ReadEntity ¶
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
An individual route
func (*Route) Matches ¶
Matches the provided request or not; returns the details of the match if successful, otherwise nil.
func (*Route) Use ¶
Use applies middleware to a route. Route-level middleware is applied in the order it is declared BEFORE router-level middleware, that is, nested more deeply.
In order to accomplish this, resolution of middleware is deferred until the first time a route is matched via Router.Find() (or, until init() is explicitly called on a route).
func (*Route) With ¶ added in v2.2.0
func (r *Route) With(opts ...RouteOption) *Route
With allows the caller to functionally configure the route by providing options that operate on the receiver