Documentation ¶
Index ¶
- Constants
- type CheckField
- type Context
- func (c *Context) AddRetError(err error)
- func (c *Context) CheckField(fields []*CheckField) (map[string]any, error)
- func (c *Context) ParamDataArrayInt(name string, desc string, require bool, min int64, max int64) (bool, []int64, error)
- func (c *Context) ParamDataArrayString(name string, desc string, require bool, min int64, max int64, reg string) (bool, []string, error)
- func (c *Context) ParamDataInt(name string, desc string, require bool, min int64, max int64, def int64) (bool, int64, error)
- func (c *Context) ParamDataString(name string, desc string, require bool, min int64, max int64, def string) (bool, string, error)
- func (c *Context) WebSocket() (*websocket.Conn, error)
Constants ¶
View Source
const ( CheckInt int = iota CheckString CheckArrayInt CheckArrayString )
批量检测参数
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckField ¶
type CheckField struct { Name string Desc string CheckType int Request bool //是否必填 Min int64 //最小值或最小长度 Max int64 //最大值或最大长度 Def any //默认值 Reg string //正则规则校验 }
CheckField 待检测字段及规则
type Context ¶
type Context struct { Ctx context.Context ResponseWriter http.ResponseWriter Request *http.Request StartTime time.Time //记录请求开始处理时间 Path string Method string RequestId string StructName string //最终调用的struct name MethodName string //最终调用的方法 //Post url.Values //单纯的form-data请求数据 或者x-www-form-urlencoded请求数据 GetPost url.Values //get参数与 form-data或者x-www-form-urlencoded合集 BodyData []byte //body内包含的数据 JsonData map[string]string //post + application/json 的情况下,解析后的json数据 [仅限简单结构-请看使用文档] ClientIp string //客户端IP // 处理返回信息 CustomRet bool //自定义处理返回信息 跳过统一返回处理 RetError string RetCode int RetData any }
Context 处理请求上下文
func NewContext ¶
func (*Context) CheckField ¶
func (c *Context) CheckField(fields []*CheckField) (map[string]any, error)
func (*Context) ParamDataArrayInt ¶
func (*Context) ParamDataArrayString ¶
func (*Context) ParamDataInt ¶
func (c *Context) ParamDataInt(name string, desc string, require bool, min int64, max int64, def int64) (bool, int64, error)
ParamDataInt 检查参数并返回数字
Click to show internal directories.
Click to hide internal directories.