Documentation
¶
Index ¶
- Variables
- func CtxError(ctx echo.Context, code int, msg ...string) error
- func CtxResult(ctx echo.Context, res *Result) error
- func CtxSuccess(ctx echo.Context, data interface{}, msg ...string) error
- func ErrorHandler(err error, ctx echo.Context)
- func FileAssets(ctx echo.Context, storeRoot string) error
- type Context
- func (c *Context) Bind(req interface{}) error
- func (c *Context) BindValid(req interface{}) error
- func (c *Context) CaptchaCheck(key string, captcha string) bool
- func (c *Context) CaptchaNew(key string, width, height int, setOpt ...captcha.SetOption) error
- func (c *Context) Echo() echo.Context
- func (c *Context) Error(err error) error
- func (c *Context) JsonError(code int, msg ...string) error
- func (c *Context) JsonSuccess(data interface{}, msg ...string) error
- func (c *Context) SessClean()
- func (c *Context) SessDel(key ...interface{})
- func (c *Context) SessFlash(key ...string) []interface{}
- func (c *Context) SessFlashAdd(val interface{}, key ...string)
- func (c *Context) SessGet(key interface{}) interface{}
- func (c *Context) SessGetValues() map[interface{}]interface{}
- func (c *Context) SessHas(key interface{}) bool
- func (c *Context) SessId() string
- func (c *Context) SessOpts() *sessions.Options
- func (c *Context) SessOptsSet(opts *sessions.Options)
- func (c *Context) SessSet(key, val interface{})
- func (c *Context) SessSetValues(values map[interface{}]interface{})
- func (c *Context) Session() *sessions.Session
- func (c *Context) SessionDo(closure func(*sessions.Session) interface{}) interface{}
- type Result
- type Server
- type ServerWith
- func WithAddr(addr string) ServerWith
- func WithAssets(prefix string, handler echo.HandlerFunc) ServerWith
- func WithCORS(origins ...string) ServerWith
- func WithDebug(debug bool) ServerWith
- func WithGzip() ServerWith
- func WithRouter(prefix string, routes ...func(g *echo.Group)) ServerWith
- func WithSecure() ServerWith
- func WithSession(store string, secret string) ServerWith
- func WithValidator(validator echo.Validator) ServerWith
- func WithView(prefix string, fs http.FileSystem, uri ...string) ServerWith
- type Upload
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Opts = &struct { ReadTimeout int64 // 读取超时 WriteTimeout int64 // 写入超时 }{} Flags = []cli.Flag{ &cli.Int64Flag{ Name: "web_read_timeout", Usage: "Web读取超时. 单位秒", EnvVars: []string{"WEB_READ_TIMEOUT"}, Value: 30, Destination: &Opts.ReadTimeout, }, &cli.Int64Flag{ Name: "web_white_timeout", Usage: "Web写入超时. 单位秒", EnvVars: []string{"WEB_WHITE_TIMEOUT"}, Value: 30, Destination: &Opts.WriteTimeout, }, } )
View Source
var (
DefaultMaxHeaderBytes = 1024 // 默认Header大小限制
)
Functions ¶
func CtxSuccess ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext(ctx echo.Context) *Context
func (*Context) CaptchaCheck ¶
验证验证码
func (*Context) CaptchaNew ¶
创建验证码
func (*Context) JsonSuccess ¶
func (*Context) SessFlashAdd ¶
func (*Context) SessGetValues ¶
func (c *Context) SessGetValues() map[interface{}]interface{}
func (*Context) SessOptsSet ¶
func (*Context) SessSetValues ¶
func (c *Context) SessSetValues(values map[interface{}]interface{})
type Result ¶
type Result struct { Code int `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` Time int64 `json:"time"` }
func ParseError ¶
type ServerWith ¶
type ServerWith func(s *Server)
func WithAddr ¶
func WithAddr(addr string) ServerWith
func WithDebug ¶
func WithDebug(debug bool) ServerWith
func WithRouter ¶
func WithRouter(prefix string, routes ...func(g *echo.Group)) ServerWith
WithRouter 注册路由
func WithSecure ¶
func WithSecure() ServerWith
func WithValidator ¶
func WithValidator(validator echo.Validator) ServerWith
type Upload ¶
type Upload struct { SaveFile string `json:"save_file"` // 保存文件 FileName string `json:"file_name"` // 文件名称 FileSize int64 `json:"file_size"` // 文件大小 OldName string `json:"old_name"` // 原始名称 }
上传文件返回的结果
func FileUpload ¶
func FileUpload(file *multipart.FileHeader, storeRoot, savePath string) (*Upload, error)
上传文件
Source Files
¶
Click to show internal directories.
Click to hide internal directories.