Documentation ¶
Index ¶
- type Context
- func (ctx *Context) BaseContext() context.Context
- func (ctx *Context) BinJson(obj any) error
- func (ctx *Context) BindXml(obj any) error
- func (ctx *Context) ClientIp() string
- func (ctx *Context) Cookie(key string) (string, bool)
- func (ctx *Context) Cookies() map[string]string
- func (ctx *Context) Deadline() (deadline time.Time, ok bool)
- func (ctx *Context) Done() <-chan struct{}
- func (ctx *Context) Err() error
- func (ctx *Context) Form(key string) any
- func (ctx *Context) FormAll() map[string][]string
- func (ctx *Context) FormBool(key string, def bool) (bool, bool)
- func (ctx *Context) FormFile(key string) (*multipart.FileHeader, error)
- func (ctx *Context) FormFloat32(key string, def float32) (float32, bool)
- func (ctx *Context) FormFloat64(key string, def float64) (float64, bool)
- func (ctx *Context) FormInt(key string, def int) (int, bool)
- func (ctx *Context) FormInt64(key string, def int64) (int64, bool)
- func (ctx *Context) FormString(key string, def string) (string, bool)
- func (ctx *Context) FormStringSlice(key string, def []string) ([]string, bool)
- func (ctx *Context) GetRawData() ([]byte, error)
- func (ctx *Context) GetRequst() *http.Request
- func (ctx *Context) GetResponse() http.ResponseWriter
- func (ctx *Context) HasTimeout() bool
- func (ctx *Context) Header(key string) (string, bool)
- func (ctx *Context) Headers() map[string][]string
- func (ctx *Context) Host() string
- func (ctx *Context) Html(file string, obj any) IResponse
- func (ctx *Context) Json(obj any) IResponse
- func (ctx *Context) Jsonp(obj any) IResponse
- func (ctx *Context) Method() string
- func (ctx *Context) Next() error
- func (ctx *Context) Param(key string) any
- func (ctx *Context) ParamBool(key string, def bool) (bool, bool)
- func (ctx *Context) ParamFloat32(key string, def float32) (float32, bool)
- func (ctx *Context) ParamFloat64(key string, def float64) (float64, bool)
- func (ctx *Context) ParamInt(key string, def int) (int, bool)
- func (ctx *Context) ParamInt64(key string, def int64) (int64, bool)
- func (ctx *Context) ParamString(key string, def string) (string, bool)
- func (ctx *Context) Query(key string) any
- func (ctx *Context) QueryAll() map[string][]string
- func (ctx *Context) QueryBool(key string, def bool) (bool, bool)
- func (ctx *Context) QueryFloat32(key string, def float32) (float32, bool)
- func (ctx *Context) QueryFloat64(key string, def float64) (float64, bool)
- func (ctx *Context) QueryInt(key string, def int) (int, bool)
- func (ctx *Context) QueryInt64(key string, def int64) (int64, bool)
- func (ctx *Context) QueryString(key, def string) (string, bool)
- func (ctx *Context) QueryStringSlice(key string, def []string) ([]string, bool)
- func (ctx *Context) Redirect(path string) IResponse
- func (ctx *Context) SetCookie(key string, val string, maxAge int, path, domain string, secure, httpOnly bool) IResponse
- func (ctx *Context) SetHandlers(handlers []ControllerHandler)
- func (ctx *Context) SetHasTimeout()
- func (ctx *Context) SetHeader(key string, val string) IResponse
- func (ctx *Context) SetOkStatus() IResponse
- func (ctx *Context) SetParams(params map[string]string)
- func (ctx *Context) SetStatus(code int) IResponse
- func (ctx *Context) Text(format string, values ...any) IResponse
- func (ctx *Context) Uri() string
- func (ctx *Context) Value(key any) any
- func (ctx *Context) WriterMux() *sync.Mutex
- func (ctx *Context) Xml(obj any) IResponse
- type ControllerHandler
- type Core
- func (c *Core) Delete(url string, handler ...ControllerHandler)
- func (c *Core) FindRouteNodeByRequest(request *http.Request) *node
- func (c *Core) Get(url string, handler ...ControllerHandler)
- func (c *Core) Group(prefix string) IGroup
- func (c *Core) Post(url string, handler ...ControllerHandler)
- func (c *Core) Put(url string, handler ...ControllerHandler)
- func (c *Core) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (c *Core) Use(middlewares ...ControllerHandler)
- type Group
- func (g *Group) Delete(uri string, handlers ...ControllerHandler)
- func (g *Group) Get(uri string, handlers ...ControllerHandler)
- func (g *Group) Group(uri string) IGroup
- func (g *Group) Post(uri string, handlers ...ControllerHandler)
- func (g *Group) Put(uri string, handlers ...ControllerHandler)
- func (g *Group) Use(middlewares ...ControllerHandler)
- type IGroup
- type IResponse
- type IRquest
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext(r *http.Request, w http.ResponseWriter) *Context
func (*Context) BaseContext ¶
func (*Context) FormFloat32 ¶
func (*Context) FormFloat64 ¶
func (*Context) FormStringSlice ¶
func (*Context) GetResponse ¶
func (ctx *Context) GetResponse() http.ResponseWriter
func (*Context) HasTimeout ¶
func (*Context) ParamFloat32 ¶
func (*Context) ParamFloat64 ¶
func (*Context) ParamString ¶
func (*Context) QueryFloat32 ¶
func (*Context) QueryFloat64 ¶
func (*Context) QueryStringSlice ¶
func (*Context) SetHandlers ¶
func (ctx *Context) SetHandlers(handlers []ControllerHandler)
func (*Context) SetHasTimeout ¶
func (ctx *Context) SetHasTimeout()
type ControllerHandler ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
func (*Core) Delete ¶
func (c *Core) Delete(url string, handler ...ControllerHandler)
匹配DELETE方法, 增加路由规则
func (*Core) FindRouteNodeByRequest ¶
匹配路由,如果没有匹配到,返回nil
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Use ¶
func (g *Group) Use(middlewares ...ControllerHandler)
type IGroup ¶
type IGroup interface { // 实现HttpMethod方法 Get(string, ...ControllerHandler) Post(string, ...ControllerHandler) Put(string, ...ControllerHandler) Delete(string, ...ControllerHandler) // 实现嵌套group Group(string) IGroup // 嵌套中间件 Use(middlewares ...ControllerHandler) }
IGroup 代表前缀分组
type IResponse ¶
type IResponse interface { // json输出 Json(obj any) IResponse // jsonp输出 Jsonp(obj any) IResponse // xml输出 Xml(obj any) IResponse // html输出 Html(file string, obj any) IResponse // string Text(format string, values ...any) IResponse // 重定向 Redirect(path string) IResponse // header SetHeader(key string, val string) IResponse // Cookie SetCookie(key string, val string, maxAge int, path, domain string, secure, httpOnly bool) IResponse // 设置状态码 SetStatus(code int) IResponse // 设置200状态 SetOkStatus() IResponse }
type IRquest ¶
type IRquest interface { // 请求地址url中带的参数 // 形如: foo.com?a=1&b=bar&c[]=bar QueryInt(key string, def int) (int, bool) QueryInt64(key string, def int64) (int64, bool) QueryFloat32(key string, def float32) (float32, bool) QueryFloat64(key string, def float64) (float64, bool) QueryBool(key string, def bool) (bool, bool) QueryString(key string, def string) (string, bool) QueryStringSlice(key string, def []string) ([]string, bool) Query(key string) any // 路由匹配中带的参数 // 形如 /book/:id ParamInt(key string, def int) (int, bool) ParamInt64(key string, def int64) (int64, bool) ParamFloat32(key string, def float32) (float32, bool) ParamFloat64(key string, def float64) (float64, bool) ParamBool(key string, def bool) (bool, bool) ParamString(key string, def string) (string, bool) Param(key string) any // form表单中带的参数 FormInt(key string, def int) (int, bool) FormInt64(key string, def int64) (int64, bool) FormFloat32(key string, def float32) (float32, bool) FormFloat64(key string, def float64) (float64, bool) FormBool(key string, def bool) (bool, bool) FormString(key string, def string) (string, bool) FormStringSlice(key string, def []string) ([]string, bool) FormFile(key string) (*multipart.FileHeader, error) Form(key string) any // json body BindJson(obj any) error // xml body BindXml(obj any) error // 其他格式 GetRawData() ([]byte, error) // 基础信息 Uri() string Method() string Host() string ClientIp() string // header Headers() map[string][]string Header(key string) (string, bool) // cookie Cookies() map[string]string Cookie(string) (string, bool) }
代表请求包含的方法
Source Files ¶
Click to show internal directories.
Click to hide internal directories.