Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorLogRecover(c echo.Context)
- type Js
- func (j *Js) Arrayindex(i int) string
- func (j *Js) Get(key string) *Js
- func (j *Js) Getdata() map[string]interface{}
- func (j *Js) Getindex(i int) *Js
- func (j *Js) Getkey(key string, i int) *Js
- func (j *Js) Getpath(args ...string) *Js
- func (j *Js) StringtoArray() []string
- func (j *Js) ToArray() (k, d []string)
- func (j *Js) ToData() interface{}
- func (j *Js) ToFloat() float64
- func (j *Js) ToInt() int
- func (j *Js) ToSlice() []interface{}
- func (j *Js) Tostring() string
- type Jsonparam
- type Request
- func (this *Request) Alpha() *Request
- func (this *Request) AlphaDash() *Request
- func (this *Request) AlphaNumeric() *Request
- func (this *Request) Base64() *Request
- func (this *Request) Clean()
- func (this *Request) Email() *Request
- func (this *Request) GetError() error
- func (this *Request) GetFloat() float64
- func (this *Request) GetInt() int
- func (this *Request) GetJson() gjson.Result
- func (this *Request) GetJsonObject(jsonInterface interface{}) interface{}
- func (this *Request) GetParam(key string) *Request
- func (this *Request) GetRoot() *Request
- func (this *Request) GetString() string
- func (this *Request) IP() *Request
- func (this *Request) InitDES() error
- func (this *Request) InitRawJson() error
- func (this *Request) InitWithoutDES() error
- func (this *Request) Match(match string) *Request
- func (this *Request) Max(i int) *Request
- func (this *Request) Min(i int) *Request
- func (this *Request) Mobile() *Request
- func (this *Request) NeedValid(b bool) *Request
- func (this *Request) NoMatch(match string) *Request
- func (this *Request) Numeric() *Request
- func (this *Request) Param(key string) *Request
- func (this *Request) Phone() *Request
- func (this *Request) PostParam(key string) *Request
- func (this *Request) Require(b bool) *Request
- func (this *Request) SetDefault(val string) *Request
- func (this *Request) SetJson(json string)
- func (this *Request) Tel() *Request
- func (this *Request) ZipCode() *Request
- type Response
- func (this *Response) GetParameter() *RetParameter
- func (this *Response) RetCustomize(code int, d interface{}, msg string) error
- func (this *Response) RetError(e error, c int) error
- func (this *Response) RetSuccess(d interface{}) error
- func (this *Response) SetData(d interface{})
- func (this *Response) SetMsg(s string)
- func (this *Response) SetStatus(i int)
- func (this *Response) Write(b []byte)
- type RetParameter
Constants ¶
View Source
const DefaultCode = 1
Variables ¶
View Source
var ( ErrNoParams = errors.New("No params") ErrMD5 = errors.New("MD5 Check Error") ErrCustom = func(str string) error { return errors.New(str) } RequestBody = "requestBody" )
View Source
var HttpStatus = http.StatusOK
Functions ¶
Types ¶
type Js ¶
type Js struct {
Data interface{}
}
func (*Js) Arrayindex ¶
When the data {"result":["username","password"]} can use arrayindex(1) get the username
func (*Js) Getkey ¶
The data must be []interface{} ,According to your custom number to return your key and array data
type Request ¶
type Request struct { Context echo.Context Jsonparam *Jsonparam Json gjson.Result IsJsonParam bool Debug bool // contains filtered or unexported fields }
func (*Request) GetJsonObject ¶ added in v1.1.1
func (this *Request) GetJsonObject(jsonInterface interface{}) interface{}
获取并且验证参数 入参为json对应的结构体 适用于GET或POST参数
示例 request := api.NewRequest(c) err := request.InitDES() if err != nil { //deal error } jsonObject := struct { Id int Name string `valid:"Required;"` // Name 不能为空 Age int `valid:"Range(1, 140)"` // 1 <= Age <= 140,超出此范围即为不合法 Email string `valid:"Email; MaxSize(100)"` // Email 字段需要符合邮箱格式,并且最大长度不能大于 100 个字符 Mobile string `valid:"Mobile"` // Mobile 必须为正确的手机号 IP string `valid:"IP"` // IP 必须为一个正确的 IPv4 地址 }{} //获取params字段内数据就符合json的结构体 root := request.GetRoot().NeedValid(true).GetJsonObject(&jsonObject) //获取params内key字段符合json的结构体 key := request.Param("key").NeedValid(true).GetJsonObject(&jsonObject) err = request.GetError() if err != nil { //deal error }
func (*Request) InitRawJson ¶ added in v1.1.0
初始化restful-raw参数
func (*Request) InitWithoutDES ¶ added in v1.1.9
跳过签名和加密
func (*Request) SetDefault ¶
type Response ¶
type Response struct { Context echo.Context // contains filtered or unexported fields }
func (*Response) GetParameter ¶ added in v1.1.1
func (this *Response) GetParameter() *RetParameter
func (*Response) RetCustomize ¶
返回自定自定义的消息格式
func (*Response) RetSuccess ¶
返回成功的结果 默认code为1
type RetParameter ¶
Click to show internal directories.
Click to hide internal directories.