Documentation
¶
Index ¶
- Constants
- type Context
- func (c *Context) BadRequest(message string)
- func (c *Context) Bind(obj interface{}) error
- func (c *Context) BindUser(val interface{})
- func (c *Context) Error(code int, message string)
- func (c *Context) File(filepath string)
- func (c *Context) FindBool(key string) bool
- func (c *Context) FindDefaultBool(key string, defaultValue bool) bool
- func (c *Context) FindDefaultInt(key string, defaultValue int) int
- func (c *Context) FindDefaultString(key string, defaultValue string) string
- func (c *Context) FindInt(key string) int
- func (c *Context) FindString(key string) string
- func (c *Context) Forbidden(message string)
- func (c *Context) Get(key string) (interface{}, bool)
- func (c *Context) GetBindUser(recipient interface{}) error
- func (c *Context) GetString(key string) string
- func (c *Context) HTML(code int, html string)
- func (c *Context) InternalServerError(message string)
- func (c *Context) JSON(code int, data interface{})
- func (c *Context) NotFound(message string)
- func (c *Context) Redirect(code int, location string)
- func (c *Context) Set(key string, value interface{})
- func (c *Context) String(code int, format string, values ...interface{})
- func (c *Context) Success(data interface{})
- func (c *Context) Unauthorized(message string)
- func (c *Context) Valid(obj interface{}) error
- func (c *Context) ValidField(rules Rules) error
- type Response
- type ResponseType
- type Rules
Constants ¶
View Source
const (
UserBindKey = "bind_user"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
Writer http.ResponseWriter
Request *http.Request
// contains filtered or unexported fields
}
Context 封装请求上下文
func (*Context) FindDefaultBool ¶
FindDefaultBool 查找布尔参数,支持默认值
func (*Context) FindDefaultInt ¶
FindDefaultInt 查找整数参数,支持默认值
func (*Context) FindDefaultString ¶
FindDefaultString 查找字符串参数,支持默认值
func (*Context) GetBindUser ¶
GetBindUser 获取绑定的用户信息
func (*Context) InternalServerError ¶
InternalServerError 返回500错误
type Response ¶
type Response struct {
Code int `json:"code"` // 状态码
Message string `json:"message,omitempty"` // 消息
Data interface{} `json:"data,omitempty"` // 数据
}
Response 标准响应结构
type ResponseType ¶
type ResponseType int
ResponseType 定义响应类型
const ( // ResponseTypeJSON JSON响应类型 ResponseTypeJSON ResponseType = iota // ResponseTypeXML XML响应类型 ResponseTypeXML // ResponseTypeHTML HTML响应类型 ResponseTypeHTML // ResponseTypeText 文本响应类型 ResponseTypeText )
Click to show internal directories.
Click to hide internal directories.