Documentation ¶
Index ¶
- type Resource
- func (r Resource) Connect(handler types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Delete(handler types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Get(handler types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Head(handler types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Options(handler types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Patch(handler types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Post(handler types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Put(handler types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Route(method method.Method, fun types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Trace(handler types.Handler, mwares ...types.Middleware) Resource
- func (r Resource) Use(middlewares ...types.Middleware) Resource
- type Router
- func (r *Router) Connect(path string, handler types.Handler, middlewares ...types.Middleware) *Router
- func (r *Router) Delete(path string, handler types.Handler, middlewares ...types.Middleware) *Router
- func (r *Router) Get(path string, handler types.Handler, middlewares ...types.Middleware) *Router
- func (r *Router) Group(prefix string) *Router
- func (r *Router) Head(path string, handler types.Handler, middlewares ...types.Middleware) *Router
- func (r *Router) OnError(request *http.Request, err error) http.Response
- func (r *Router) OnRequest(request *http.Request) http.Response
- func (r *Router) OnStart() error
- func (r *Router) Options(path string, handler types.Handler, middlewares ...types.Middleware) *Router
- func (r *Router) Patch(path string, handler types.Handler, middlewares ...types.Middleware) *Router
- func (r *Router) Post(path string, handler types.Handler, middlewares ...types.Middleware) *Router
- func (r *Router) Put(path string, handler types.Handler, middlewares ...types.Middleware) *Router
- func (r *Router) Resource(path string) Resource
- func (r *Router) Route(method method.Method, path string, handlerFunc types.Handler, ...) *Router
- func (r *Router) RouteError(err error, handler types.Handler)
- func (r *Router) Trace(path string, handler types.Handler, middlewares ...types.Middleware) *Router
- func (r *Router) Use(middlewares ...types.Middleware) *Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource is just a wrapper of a group for some resource, allowing to attach multiple methods (and pointed-applied middlewares) to some single resource in a bit more convenient way than ordinary groups do. Actually, the only point of this object is to wrap a group to bypass an empty string into it as a path
func (Resource) Route ¶
func (r Resource) Route(method method.Method, fun types.Handler, mwares ...types.Middleware) Resource
Route is a shortcut to group.Route, providing the extra empty path to the call
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is a built-in implementation of router.Router interface that provides some basic router features like middlewares, groups, dynamic routing, error handlers, and some implicit things like calling GET-handlers for HEAD-requests, or rendering TRACE-responses automatically in case no handler is registered
func (*Router) Connect ¶
func (r *Router) Connect(path string, handler types.Handler, middlewares ...types.Middleware) *Router
Connect is a shortcut for registering CONNECT-requests
func (*Router) Delete ¶
func (r *Router) Delete(path string, handler types.Handler, middlewares ...types.Middleware) *Router
Delete is a shortcut for registering DELETE-requests
func (*Router) Group ¶
Group creates a new router with pre-defined prefix for all paths. It'll automatically be merged into the head router on server start. Middlewares, applied on this router, will not affect the head router, but initially head router's middlewares will be inherited and will be called in the first order. Registering new error handlers will result in affecting error handlers among ALL the existing groups, including head router
func (*Router) OnError ¶
OnError tries to find a handler for the error, in case it can't - simply request.Respond().WithError(...) will be returned
func (*Router) Options ¶
func (r *Router) Options(path string, handler types.Handler, middlewares ...types.Middleware) *Router
Options is a shortcut for registering OPTIONS-requests
func (*Router) Route ¶
func (r *Router) Route( method method.Method, path string, handlerFunc types.Handler, middlewares ...types.Middleware, ) *Router
Route is a base method for registering handlers
func (*Router) RouteError ¶
RouteError adds an error handler. You can handle next errors: - status.ErrBadRequest - status.ErrNotFound - status.ErrMethodNotAllowed - status.ErrTooLarge - status.ErrCloseConnection - status.ErrURITooLong - status.ErrHeaderFieldsTooLarge - status.ErrTooManyHeaders - status.ErrUnsupportedProtocol - status.ErrUnsupportedEncoding - status.ErrMethodNotImplemented - status.ErrConnectionTimeout
You can set your own handler and override default response WARNING: calling this method from groups will affect ALL routers, including root