Documentation ¶
Index ¶
- func Handle(next HandlerFunc) echo.HandlerFunc
- type Context
- func (c *Context) Bind(i interface{}) error
- func (c *Context) GetUser() *db.User
- func (c *Context) OutputJSON(Code int, message string, options ...JSONOption) error
- func (c *Context) QueryInt(key string) (val int, err error)
- func (c *Context) QueryUint(key string) (val uint, err error)
- func (c *Context) Success(options ...JSONOption) error
- func (c *Context) WithData(data interface{}) JSONOption
- func (c *Context) WithStatusCode(status int) JSONOption
- type HandlerFunc
- type JSONOption
- type JSONResult
- type Pagination
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handle ¶
func Handle(next HandlerFunc) echo.HandlerFunc
Types ¶
type Context ¶
type Context struct {
echo.Context
}
func (*Context) OutputJSON ¶
func (c *Context) OutputJSON(Code int, message string, options ...JSONOption) error
Output JSON
Example:
c.OutputJSON(0, "success", c.WithStatusCode(http.StatusOK), c.WithData("hello,world"))
func (*Context) QueryUint ¶ added in v0.4.0
QueryUint get uint from query. if query[key] < 0, return error.
func (*Context) Success ¶ added in v0.4.0
func (c *Context) Success(options ...JSONOption) error
func (*Context) WithData ¶ added in v0.3.0
func (c *Context) WithData(data interface{}) JSONOption
WithData set "data" field
func (*Context) WithStatusCode ¶ added in v0.3.0
func (c *Context) WithStatusCode(status int) JSONOption
WithStatusCode set http status code
type HandlerFunc ¶
type JSONOption ¶ added in v0.3.0
type JSONOption func(res *JSONResult)
type JSONResult ¶
type JSONResult struct { Status int `json:"-"` Code int `json:"code"` Message string `json:"msg"` Data interface{} `json:"data,omitempty"` }
JSONResult json
type Pagination ¶
type Pagination struct { Total int64 `json:"total"` // total: 全部记录条数 和 antd 参数一致 Current int `json:"current"` // current:当前页数,和 antd 翻页参数一致 }
Pagination
Click to show internal directories.
Click to hide internal directories.