Documentation ¶
Index ¶
- Constants
- Variables
- type CheckField
- type CommonParam
- type Con
- func (c *Con) CheckField(fields []*CheckField) (map[string]interface{}, error)
- func (c *Con) CheckParamInt(param string, dec string, request bool, min int64, max int64, def string) (int64, error)
- func (c *Con) CheckParamString(param string, dec string, request bool, min int64, max int64, def string) (string, error)
- func (c *Con) JsonReturn(code int, data interface{}, format string, a ...interface{})
- func (c *Con) WebSocket() (*websocket.Conn, error)
- func (c *Con) YewuParamInt(param string, dec string, request bool, min int64, max int64, def string) (int64, error)
- func (c *Con) YewuParamString(param string, dec string, request bool, min int64, max int64, def string) (string, error)
- type YewuParam
Constants ¶
View Source
const ( CHECK_INT checkType = 0 CHECK_STRING checkType = 1 )
Variables ¶
View Source
var ( // JSONRETURN 提前退出http请求使用 JSONRETURN = errors.New("") TEXTRETURN = errors.New("") )
Functions ¶
This section is empty.
Types ¶
type CheckField ¶ added in v0.0.10
type CheckField struct { Name string Dec string Tpe checkType Request bool //是否必填 Def string //默认值 Min int64 //最小值或最小长度 Max int64 //最大值或最大长度 Yewu bool //是否为业务参数 Reg string //正则规则校验 }
CheckField 用于检查数据的结构信息 checkType 当前仅支持int64 和 string max = 0 表示不限制长度/大小 reg数据校验,多个用|分割 待支持:mobile email ...
type CommonParam ¶
type CommonParam struct { AppKey string `json:"app_key"` Control string `json:"control"` Method string `json:"method"` Ip string `json:"ip"` Sign string `json:"sign"` Param string `json:"param"` //业务参数部分 }
CommonParam 公共参数
type Con ¶
type Con struct { Request *http.Request ResponseWriter http.ResponseWriter RequestId string //分布式唯一ID Header http.Header ClassName string MethodName string Post url.Values //单纯的form-data请求数据 或者x-www-form-urlencoded请求数据 GetPost url.Values //get参数与 form-data或者x-www-form-urlencoded合集 BodyData []byte //body内包含的数据 CommonParam CommonParam //公共参数 验证签名的请求使用 YewuParam YewuParam //业务参数 验证签名的请求使用 Node *snowflake.Node }
func (*Con) CheckField ¶ added in v0.0.10
func (c *Con) CheckField(fields []*CheckField) (map[string]interface{}, error)
CheckField 批量检查参数是否合法
func (*Con) CheckParamInt ¶
func (c *Con) CheckParamInt(param string, dec string, request bool, min int64, max int64, def string) (int64, error)
CheckParamInt 检测外部访问来的参数 转换为int返回 GET POST参数检测并转换为string dec 字段描述 request 是否必填 min 最小值 max 最大允许值
func (*Con) CheckParamString ¶
func (c *Con) CheckParamString(param string, dec string, request bool, min int64, max int64, def string) (string, error)
CheckParamString 检测外部访问来的参数 GET POST参数检测并转换为string dec 参数描述 request 是否必填 min 0不判断最小长度 max 0 强制max = 65535 判断最大长度 def 默认值
func (*Con) JsonReturn ¶
Click to show internal directories.
Click to hide internal directories.