Documentation
¶
Index ¶
- Variables
- type API
- func (api *API) All(pattern string, handle Handler)
- func (api *API) Delete(pattern string, handle Handler)
- func (api *API) Get(pattern string, handle Handler)
- func (api *API) Head(pattern string, handle Handler)
- func (api *API) OnError(code string, handle Handler)
- func (api *API) OnErrors(codes []string, handle Handler)
- func (api *API) Options(pattern string, handle Handler)
- func (api *API) Patch(pattern string, handle Handler)
- func (api *API) Post(pattern string, handle Handler)
- func (api *API) Put(pattern string, handle Handler)
- func (api *API) Route(method string, pattern string, handle Handler)
- func (api *API) ServeHTTP(res http.ResponseWriter, req *http.Request)
- func (api *API) UnhandledException(handle Handler)
- func (api *API) Use(handle Handler)
- type Context
- func (ctx *Context) Delete(key string)
- func (ctx *Context) End()
- func (ctx *Context) Get(key string) (val interface{}, exists bool)
- func (ctx *Context) GetError() error
- func (ctx *Context) JSON(data interface{})
- func (ctx *Context) PostSend(task Task)
- func (ctx *Context) PreSend(task Task)
- func (ctx *Context) Set(key string, val interface{})
- func (ctx *Context) SetHeader(key string, val string) *Context
- func (ctx *Context) Status(code int) *Context
- func (ctx *Context) Text(data string)
- func (ctx *Context) Throw(code string)
- func (ctx *Context) ThrowWithError(code string, err error)
- func (ctx *Context) Write(data []byte)
- type Handler
- type Namespace
- func (n *Namespace) All(pattern string, handle Handler)
- func (n *Namespace) Delete(pattern string, handle Handler)
- func (n *Namespace) Get(pattern string, handle Handler)
- func (n *Namespace) Head(pattern string, handle Handler)
- func (n *Namespace) OnError(code string, handle Handler)
- func (n *Namespace) Options(pattern string, handle Handler)
- func (n *Namespace) Patch(pattern string, handle Handler)
- func (n *Namespace) Post(pattern string, handle Handler)
- func (n *Namespace) Put(pattern string, handle Handler)
- func (n *Namespace) Use(handle Handler)
- type Task
Constants ¶
This section is empty.
Variables ¶
var ( ErrCodeNotFound = "URL_NOT_FOUND" ErrCodeRuntimeError = "RUNTIME_ERROR" )
error variables to handle expected errors
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API It provides all methods, which are required to setup all kind of routes. It manages request interceptor/middlewares. which are used to intercept requests calls before performing actual operation, such as authentication, method override, request logger, etc. Also, it handles errors, which are thrown by users
func (*API) All ¶
All method is slightly similar to Use method, but in All method you can use pattern before intercepting any request
func (*API) Route ¶
Route method is used to define specific routes with handler. You can use http method, declare patten and finally you have to pass handler
func (*API) ServeHTTP ¶
func (api *API) ServeHTTP(res http.ResponseWriter, req *http.Request)
It's required handle for http module. Every request travels from this method.
func (*API) UnhandledException ¶
UnhandledException method is used to handle all unhandled exceptions
type Context ¶
type Context struct { // available to users Request *http.Request Response http.ResponseWriter Query url.Values Body map[string]interface{} Params map[string]string // contains filtered or unexported fields }
Context, which initializes at every request with pre-declared variables such as Request, Response, Query, Body, Params etc.
func (*Context) ThrowWithError ¶
Throw an error with error
type Handler ¶
type Handler func(ctx *Context)
Handler function is used to perform a specified task on request. In handler function, you will get rest context object, which carries request, response writer objects and other methods too.
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace is used to extend routes with a specific prefix
func (*Namespace) All ¶
All method is used to execute for all methods, but with some more prefix as compare to Use method