Documentation
¶
Index ¶
- Variables
- func Purify(uri string) string
- func Upper(method string) string
- func Web404Handler(context *Context)
- func Web405Handler(context *Context)
- func WebErrHandler(context *Context, httpCode int, message string)
- type ApiResult
- type Application
- func (app *Application) Connect(uri string, handler HandlerFunc) *Application
- func (app *Application) Delete(uri string, handler HandlerFunc) *Application
- func (app *Application) Get(uri string, handler HandlerFunc) *Application
- func (app *Application) GetRouter() *Router
- func (app *Application) Head(uri string, handler HandlerFunc) *Application
- func (app *Application) Options(uri string, handler HandlerFunc) *Application
- func (app *Application) Patch(uri string, handler HandlerFunc) *Application
- func (app *Application) Post(uri string, handler HandlerFunc) *Application
- func (app *Application) Put(uri string, handler HandlerFunc) *Application
- func (app *Application) Route(methods []string, uri string, handler HandlerFunc) *Application
- func (app *Application) Run(ip string, port int)
- func (app *Application) Trace(uri string, handler HandlerFunc) *Application
- func (app *Application) Use(middlewares ...HandlerFunc) *Application
- type Context
- func (context *Context) BoolParam(name string, defaultValue bool) bool
- func (context *Context) BytesParam(name string, defaultValue []byte) []byte
- func (context *Context) ConnRequestNum() uint64
- func (context *Context) ConnTime() string
- func (context *Context) Err(msg string)
- func (context *Context) Finish(code int, msg string, data interface{})
- func (context *Context) FloatParam(key string, defaultValue float64) float64
- func (context *Context) Host() string
- func (context *Context) IntParam(key string, defaultValue int) int
- func (context *Context) Next()
- func (context *Context) Ok(data interface{})
- func (context *Context) Path() string
- func (context *Context) PostArgs() *fasthttp.Args
- func (context *Context) QueryArgs() *fasthttp.Args
- func (context *Context) Redirect(url string)
- func (context *Context) RemoteIP() string
- func (context *Context) RenderHtml(data string)
- func (context *Context) RenderJson(data interface{})
- func (context *Context) RenderString(data string)
- func (context *Context) Request() *fasthttp.Request
- func (context *Context) RequestURI() string
- func (context *Context) SetContentType(contentType string) *Context
- func (context *Context) SetCookie(name string, value string) *Context
- func (context *Context) SetHeader(name string, value string) *Context
- func (context *Context) StrParam(name string, defaultValue string) string
- func (context *Context) Time() string
- func (context *Context) UserAgent() string
- func (context *Context) Write(p []byte) (int, error)
- func (context *Context) WriteString(s string) (int, error)
- type DynRouteNode
- type HandlerFunc
- type MethodHandler
- type MiddlewareFunc
- type Router
- type StaticRoute
Constants ¶
This section is empty.
Variables ¶
View Source
var SUPPORT_METHODS = []string{"GET", "HEAD", "POST", "DELETE", "PATCH", "PUT", "OPTIONS"}
View Source
var SUPPORT_METHOD_SET = func() map[string]int { m := make(map[string]int) for _, key := range SUPPORT_METHODS { m[key] = 0 } return m }()
Functions ¶
func Web404Handler ¶
func Web404Handler(context *Context)
func Web405Handler ¶
func Web405Handler(context *Context)
func WebErrHandler ¶
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func New ¶
func New() Application
func (*Application) Connect ¶
func (app *Application) Connect(uri string, handler HandlerFunc) *Application
func (*Application) Delete ¶
func (app *Application) Delete(uri string, handler HandlerFunc) *Application
func (*Application) Get ¶
func (app *Application) Get(uri string, handler HandlerFunc) *Application
func (*Application) GetRouter ¶
func (app *Application) GetRouter() *Router
func (*Application) Head ¶
func (app *Application) Head(uri string, handler HandlerFunc) *Application
func (*Application) Options ¶
func (app *Application) Options(uri string, handler HandlerFunc) *Application
func (*Application) Patch ¶
func (app *Application) Patch(uri string, handler HandlerFunc) *Application
func (*Application) Post ¶
func (app *Application) Post(uri string, handler HandlerFunc) *Application
func (*Application) Put ¶
func (app *Application) Put(uri string, handler HandlerFunc) *Application
func (*Application) Route ¶
func (app *Application) Route(methods []string, uri string, handler HandlerFunc) *Application
func (*Application) Run ¶
func (app *Application) Run(ip string, port int)
func (*Application) Trace ¶
func (app *Application) Trace(uri string, handler HandlerFunc) *Application
func (*Application) Use ¶
func (app *Application) Use(middlewares ...HandlerFunc) *Application
type Context ¶
type Context struct { Method string SeqId string UriArgs map[string]string // contains filtered or unexported fields }
func NewContext ¶
func NewContext(fastHttpRequestCtx *fasthttp.RequestCtx) Context
func (*Context) BoolParam ¶
GetBool returns boolean value for the given key.
true is returned for "1", "t", "T", "true", "TRUE", "True", "y", "yes", "Y", "YES", "Yes", otherwise false is returned.
func (*Context) BytesParam ¶
func (*Context) ConnRequestNum ¶
func (*Context) FloatParam ¶
func (*Context) PostArgs ¶
PostArgs returns POST arguments.
It doesn't return query arguments from RequestURI - use QueryArgs for this.
Returned arguments are valid until returning from RequestHandler.
See also QueryArgs, FormValue and FormFile.
func (*Context) QueryArgs ¶
QueryArgs returns query arguments from RequestURI.
It doesn't return POST'ed arguments - use PostArgs() for this.
Returned arguments are valid until returning from RequestHandler.
See also PostArgs, FormValue and FormFile.
func (*Context) RenderHtml ¶
func (*Context) RenderJson ¶
func (context *Context) RenderJson(data interface{})
func (*Context) RenderString ¶
func (*Context) RequestURI ¶
func (*Context) SetContentType ¶
type DynRouteNode ¶
type DynRouteNode struct { Handler HandlerFunc // HandlerFunc or nil // contains filtered or unexported fields }
func NewDynRouteNode ¶
func NewDynRouteNode(path string, isEnd bool, handler HandlerFunc) DynRouteNode
func (*DynRouteNode) Add ¶
func (node *DynRouteNode) Add(child *DynRouteNode)
type HandlerFunc ¶
type HandlerFunc func(ctx *Context)
func Logger ¶
func Logger() HandlerFunc
func SeqId ¶
func SeqId() HandlerFunc
type MethodHandler ¶
type MethodHandler map[string]HandlerFunc
type MiddlewareFunc ¶
type MiddlewareFunc func() HandlerFunc
type Router ¶
type Router struct { StaticRoutes map[string]MethodHandler DynRoot DynRouteNode DynRoutesHeight int }
type StaticRoute ¶
type StaticRoute struct { Method string Uri string Handler HandlerFunc }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.