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) GetParam(key string) *Request
- func (this *Request) GetString() string
- func (this *Request) IP() *Request
- func (this *Request) InitDES() error
- func (this *Request) InitRawJson() 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) 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) 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) InitRawJson ¶ added in v1.1.0
初始化restful-raw参数
func (*Request) SetDefault ¶
type Response ¶
func (*Response) RetCustomize ¶
返回自定自定义的消息格式
func (*Response) RetSuccess ¶
返回成功的结果 默认code为1
type RetParameter ¶
Directories ¶
Path | Synopsis |
---|---|
Package validation for validations import ( "github.com/astaxie/beego/validation" "log" ) type User struct { Name string Age int } func main() { u := User{"man", 40} valid := validation.Validation{} valid.Required(u.Name, "name") valid.MaxSize(u.Name, 15, "nameMax") valid.Range(u.Age, 0, 140, "age") if valid.HasErrors() { // validation does not pass // print invalid message for _, err := range valid.Errors { log.Println(err.Key, err.Message) } } // or use like this if v := valid.Max(u.Age, 140, "ageMax"); !v.Ok { log.Println(v.Error.Key, v.Error.Message) } } more info: http://beego.me/docs/mvc/controller/validation.md
|
Package validation for validations import ( "github.com/astaxie/beego/validation" "log" ) type User struct { Name string Age int } func main() { u := User{"man", 40} valid := validation.Validation{} valid.Required(u.Name, "name") valid.MaxSize(u.Name, 15, "nameMax") valid.Range(u.Age, 0, 140, "age") if valid.HasErrors() { // validation does not pass // print invalid message for _, err := range valid.Errors { log.Println(err.Key, err.Message) } } // or use like this if v := valid.Max(u.Age, 140, "ageMax"); !v.Ok { log.Println(v.Error.Key, v.Error.Message) } } more info: http://beego.me/docs/mvc/controller/validation.md |
Click to show internal directories.
Click to hide internal directories.