Documentation ¶
Index ¶
- Constants
- func DefaultRecover(c *Context)
- type Api
- type ApiGroup
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithData(status int, data []byte)
- func (c *Context) AbortWithStatusJson(status int, o interface{}) error
- func (c *Context) Bind(api *Api, model interface{}) error
- func (c *Context) ClientIp() net.IP
- func (c *Context) ClientProxyIP() string
- func (c *Context) GetRequestHeader(key string) string
- func (c *Context) GetUserValue(key string) interface{}
- func (c *Context) Next()
- func (c *Context) Redirect(uri string, statusCode int)
- func (c *Context) Run()
- func (c *Context) SetResponseHeader(k, v string)
- func (c *Context) SetUserValue(key string, val interface{})
- func (c *Context) StdHttpRequest() *http.Request
- func (c *Context) StdResponseWriter() http.ResponseWriter
- type DocParam
- type Document
- type H
- type Handler
- type HandlerFunc
- type HandlersChain
- type Message
- type Param
- type Params
- type RouterGroup
- func (r *RouterGroup) Any(path string, handler Handler)
- func (r *RouterGroup) DELETE(path string, handler Handler)
- func (r *RouterGroup) GET(path string, handler Handler)
- func (r *RouterGroup) Group(pth string) *RouterGroup
- func (r *RouterGroup) HEAD(path string, handler Handler)
- func (r *RouterGroup) Method(method string, pth string, handler Handler)
- func (r *RouterGroup) OPTION(path string, handler Handler)
- func (r *RouterGroup) PATCH(path string, handler Handler)
- func (r *RouterGroup) POST(path string, handler Handler)
- func (r *RouterGroup) PUT(path string, handler Handler)
- func (r *RouterGroup) RegisterApis(apis []*Api) *ApiGroup
- func (r *RouterGroup) Use(handlers ...Handler)
- type Server
Constants ¶
View Source
const ( ContentTypeUrlEncode = "application/x-www-form-urlencoded" ContentTypeApplicationJson = "application/json" ContentTypeNone = "-" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Api ¶
type Api struct { Name string Method string Route string ContentType string Desc string RequestModel func() interface{} // request model factory, RequestExample interface{} // this will be part of request example of api doc HandleFunc HandlerFunc // request handler ,if null ,Handler will be use NotValidateRequest bool Handler interface{} // type must be func(*fastserver.Context,*struct{})(int,*struct{}) or func(*fastserver.Context})(int,*struct{}) ResponseExample interface{} // this will be part of response example of api doc // contains filtered or unexported fields }
type ApiGroup ¶
type ApiGroup struct { Docs []*Document ServiceName string // contains filtered or unexported fields }
func NewApiGroup ¶
func NewApiGroup(g *RouterGroup, apis []*Api) *ApiGroup
type Context ¶
type Context struct { FastCtx *fasthttp.RequestCtx Path string // 由于是从fasthttp 里面取过来的,不能够在其他的协程中使用 Method string Params Params RequestURI string // contains filtered or unexported fields }
func (*Context) AbortWithData ¶
func (*Context) AbortWithStatusJson ¶
func (*Context) ClientProxyIP ¶
func (*Context) GetRequestHeader ¶
func (*Context) GetUserValue ¶
func (*Context) SetResponseHeader ¶
func (*Context) SetUserValue ¶
func (*Context) StdResponseWriter ¶
func (c *Context) StdResponseWriter() http.ResponseWriter
获取标准的 http responseWriter
type HandlerFunc ¶
type HandlersChain ¶
type HandlersChain []Handler
func (HandlersChain) Last ¶
func (c HandlersChain) Last() Handler
type Params ¶
type Params []Param
Params is a Param-slice, as returned by the router. The slice is ordered, the first URL parameter is also the first slice value. It is therefore safe to read values by the index.
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) Any ¶
func (r *RouterGroup) Any(path string, handler Handler)
func (*RouterGroup) DELETE ¶
func (r *RouterGroup) DELETE(path string, handler Handler)
func (*RouterGroup) GET ¶
func (r *RouterGroup) GET(path string, handler Handler)
func (*RouterGroup) Group ¶
func (r *RouterGroup) Group(pth string) *RouterGroup
创建一个group,可以构建新的拦截器链路,新的group 会继承父拦截器(handler)
func (*RouterGroup) HEAD ¶
func (r *RouterGroup) HEAD(path string, handler Handler)
func (*RouterGroup) Method ¶
func (r *RouterGroup) Method(method string, pth string, handler Handler)
func (*RouterGroup) OPTION ¶
func (r *RouterGroup) OPTION(path string, handler Handler)
func (*RouterGroup) PATCH ¶
func (r *RouterGroup) PATCH(path string, handler Handler)
func (*RouterGroup) POST ¶
func (r *RouterGroup) POST(path string, handler Handler)
func (*RouterGroup) PUT ¶
func (r *RouterGroup) PUT(path string, handler Handler)
func (*RouterGroup) RegisterApis ¶
func (r *RouterGroup) RegisterApis(apis []*Api) *ApiGroup
type Server ¶
type Server struct { RouterGroup // // contains filtered or unexported fields }
http server 基于fastHttp 封装路由功能 路由部分参考gin 的路由树,支持path 参数
Source Files ¶
Click to show internal directories.
Click to hide internal directories.