Documentation ¶
Index ¶
- type Resource
- func (r Resource) Connect(handler types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Delete(handler types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Get(handler types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Head(handler types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Options(handler types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Patch(handler types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Post(handler types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Put(handler types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Route(method method.Method, fun types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Trace(handler types.HandlerFunc, mwares ...types.Middleware) Resource
- func (r Resource) Use(middlewares ...types.Middleware) Resource
- type Router
- func (r *Router) Connect(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
- func (r *Router) Delete(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
- func (r *Router) Get(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
- func (r *Router) Group(prefix string) *Router
- func (r *Router) Head(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
- func (r *Router) OnError(request *http.Request, err error) http.Response
- func (r *Router) OnRequest(request *http.Request) http.Response
- func (r *Router) OnStart()
- func (r *Router) Options(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
- func (r *Router) Patch(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
- func (r *Router) Post(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
- func (r *Router) Put(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
- func (r *Router) Resource(path string) Resource
- func (r *Router) Route(method method.Method, path string, handlerFunc types.HandlerFunc, ...)
- func (r *Router) RouteError(err error, handler types.HandlerFunc)
- func (r *Router) Trace(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
- func (r *Router) Use(middlewares ...types.Middleware)
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) Connect ¶
func (r Resource) Connect(handler types.HandlerFunc, mwares ...types.Middleware) Resource
Connect is a shortcut for registering CONNECT-requests
func (Resource) Delete ¶
func (r Resource) Delete(handler types.HandlerFunc, mwares ...types.Middleware) Resource
Delete is a shortcut for registering DELETE-requests
func (Resource) Get ¶
func (r Resource) Get(handler types.HandlerFunc, mwares ...types.Middleware) Resource
Get is a shortcut for registering GET-requests
func (Resource) Head ¶
func (r Resource) Head(handler types.HandlerFunc, mwares ...types.Middleware) Resource
Head is a shortcut for registering HEAD-requests
func (Resource) Options ¶
func (r Resource) Options(handler types.HandlerFunc, mwares ...types.Middleware) Resource
Options is a shortcut for registering OPTIONS-requests
func (Resource) Patch ¶
func (r Resource) Patch(handler types.HandlerFunc, mwares ...types.Middleware) Resource
Patch is a shortcut for registering PATCH-requests
func (Resource) Post ¶
func (r Resource) Post(handler types.HandlerFunc, mwares ...types.Middleware) Resource
Post is a shortcut for registering POST-requests
func (Resource) Put ¶
func (r Resource) Put(handler types.HandlerFunc, mwares ...types.Middleware) Resource
Put is a shortcut for registering PUT-requests
func (Resource) Route ¶
func (r Resource) Route(method method.Method, fun types.HandlerFunc, mwares ...types.Middleware) Resource
Route is a shortcut to group.Route, providing the extra empty path to the call
func (Resource) Trace ¶
func (r Resource) Trace(handler types.HandlerFunc, mwares ...types.Middleware) Resource
Trace is a shortcut for registering TRACE-requests
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.HandlerFunc, middlewares ...types.Middleware)
Connect is a shortcut for registering CONNECT-requests
func (*Router) Delete ¶
func (r *Router) Delete(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
Delete is a shortcut for registering DELETE-requests
func (*Router) Get ¶
func (r *Router) Get(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
Get is a shortcut for registering GET-requests
func (*Router) Group ¶
Group creates a new instance of InbuiltRouter, but inherited from current one Middlewares has to be inherited from a parent, but adding new middlewares in a child group MUST NOT affect parent ones, so parent middlewares are copied into child ones. Everything else is inherited from parent as it is
func (*Router) Head ¶
func (r *Router) Head(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
Head is a shortcut for registering HEAD-requests
func (*Router) OnError ¶
OnError receives an error and calls a corresponding handler. Handler MUST BE registered, otherwise panic is raised. Luckily (for user), we have all the default handlers registered
func (*Router) OnStart ¶
func (r *Router) OnStart()
OnStart composes all the registered handlers with middlewares
func (*Router) Options ¶
func (r *Router) Options(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
Options is a shortcut for registering OPTIONS-requests
func (*Router) Patch ¶
func (r *Router) Patch(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
Patch is a shortcut for registering PATCH-requests
func (*Router) Post ¶
func (r *Router) Post(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
Post is a shortcut for registering POST-requests
func (*Router) Put ¶
func (r *Router) Put(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
Put is a shortcut for registering PUT-requests
func (*Router) Route ¶
func (r *Router) Route( method method.Method, path string, handlerFunc types.HandlerFunc, middlewares ...types.Middleware, )
Route is a base method for registering handlers
func (*Router) RouteError ¶
func (r *Router) RouteError(err error, handler types.HandlerFunc)
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
func (*Router) Trace ¶
func (r *Router) Trace(path string, handler types.HandlerFunc, middlewares ...types.Middleware)
Trace is a shortcut for registering TRACE-requests
func (*Router) Use ¶
func (r *Router) Use(middlewares ...types.Middleware)
Use adds middlewares into the global list of a group's middlewares. But they will be applied only after server will be started