Documentation
¶
Index ¶
- Constants
- Variables
- func CaptureTokens(pattern *regexp.Regexp, input string) *strings.Replacer
- func ContentTypeByExtension(name string) (t string)
- func DefaultSkipper(c Context) bool
- func Dump(m interface{}, args ...bool) (r string)
- func FormNames(s string) []string
- func HandlerName(h interface{}) string
- func HandlerPath(h interface{}) string
- func HandlerTmpl(handlerPath string) string
- func Methods() []string
- func NamedStructMap(e *Echo, m interface{}, data map[string][]string, topName string, ...) error
- func StructToForm(ctx Context, m interface{}, topName string, ...)
- func Wd() string
- type Accept
- type Binder
- type Closer
- type Context
- type ContextRegister
- type Cookie
- type CookieOptions
- type Cookier
- type Data
- type DebugSession
- func (n *DebugSession) AddFlash(value interface{}, args ...string) Sessioner
- func (n *DebugSession) Clear() Sessioner
- func (n *DebugSession) Delete(name string) Sessioner
- func (n *DebugSession) Flashes(args ...string) []interface{}
- func (n *DebugSession) Get(name string) interface{}
- func (n *DebugSession) ID() string
- func (n *DebugSession) Options(options SessionOptions) Sessioner
- func (n *DebugSession) Save() error
- func (n *DebugSession) Set(name string, value interface{}) Sessioner
- func (n *DebugSession) SetID(id string) Sessioner
- type Echo
- func (e *Echo) AddAcceptFormat(mime, format string) *Echo
- func (e *Echo) AddFormatRenderer(format string, renderer func(c Context, data interface{}) error) *Echo
- func (e *Echo) AddHandlerWrapper(funcs ...func(interface{}) Handler)
- func (e *Echo) AddMiddlewareWrapper(funcs ...func(interface{}) Middleware)
- func (e *Echo) Any(path string, h interface{}, middleware ...interface{})
- func (e *Echo) AppendRouter(routes []*Route)
- func (e *Echo) Binder() Binder
- func (e *Echo) Clear(middleware ...interface{})
- func (e *Echo) Connect(path string, h interface{}, m ...interface{})
- func (e *Echo) Debug() bool
- func (e *Echo) DefaultHTTPErrorHandler(err error, c Context)
- func (e *Echo) Delete(path string, h interface{}, m ...interface{})
- func (e *Echo) Engine() engine.Engine
- func (e *Echo) File(path, file string)
- func (e *Echo) Get(path string, h interface{}, m ...interface{})
- func (e *Echo) Group(prefix string, m ...interface{}) *Group
- func (e *Echo) HTTPErrorHandler() HTTPErrorHandler
- func (e *Echo) Head(path string, h interface{}, m ...interface{})
- func (e *Echo) Logger() logger.Logger
- func (e *Echo) Match(methods []string, path string, h interface{}, middleware ...interface{})
- func (e *Echo) MetaHandler(m H, handler interface{}) Handler
- func (e *Echo) NamedRoutes() map[string][]int
- func (e *Echo) Options(path string, h interface{}, m ...interface{})
- func (e *Echo) Patch(path string, h interface{}, m ...interface{})
- func (e *Echo) Post(path string, h interface{}, m ...interface{})
- func (e *Echo) Pre(middleware ...interface{})
- func (e *Echo) PreUse(middleware ...interface{})
- func (e *Echo) Put(path string, h interface{}, m ...interface{})
- func (e *Echo) RebuildRouter(args ...[]*Route)
- func (e *Echo) RemoveFormatRenderer(formats ...string) *Echo
- func (e *Echo) Renderer() Renderer
- func (e *Echo) Route(methods string, path string, h interface{}, middleware ...interface{})
- func (e *Echo) Router() *Router
- func (e *Echo) Routes() []*Route
- func (e *Echo) Run(eng engine.Engine, handler ...engine.Handler)
- func (e *Echo) ServeHTTP(req engine.Request, res engine.Response)
- func (e *Echo) SetAcceptFormats(acceptFormats map[string]string) *Echo
- func (e *Echo) SetBinder(b Binder)
- func (e *Echo) SetDebug(on bool)
- func (e *Echo) SetFormatRenderers(formatRenderers map[string]func(c Context, data interface{}) error) *Echo
- func (e *Echo) SetHTTPErrorHandler(h HTTPErrorHandler)
- func (e *Echo) SetHandlerWrapper(funcs ...func(interface{}) Handler)
- func (e *Echo) SetLogger(l logger.Logger)
- func (e *Echo) SetMiddlewareWrapper(funcs ...func(interface{}) Middleware)
- func (e *Echo) SetRenderer(r Renderer)
- func (e *Echo) Static(prefix, root string)
- func (e *Echo) Stop() error
- func (e *Echo) Trace(path string, h interface{}, m ...interface{})
- func (e *Echo) URI(handler interface{}, params ...interface{}) string
- func (e *Echo) URL(h interface{}, params ...interface{}) string
- func (e *Echo) Use(middleware ...interface{})
- func (e *Echo) ValidHandler(v interface{}) (h Handler)
- func (e *Echo) ValidMiddleware(v interface{}) (m Middleware)
- type FieldNameFormatter
- type FormDataFilter
- type FromConversion
- type Group
- func (g *Group) Any(path string, h interface{}, middleware ...interface{})
- func (g *Group) Connect(path string, h interface{}, m ...interface{})
- func (g *Group) Delete(path string, h interface{}, m ...interface{})
- func (g *Group) Echo() *Echo
- func (g *Group) File(path, file string)
- func (g *Group) Get(path string, h interface{}, m ...interface{})
- func (g *Group) Group(prefix string, middleware ...interface{}) *Group
- func (g *Group) Head(path string, h interface{}, m ...interface{})
- func (g *Group) Match(methods []string, path string, h interface{}, middleware ...interface{})
- func (g *Group) MetaHandler(m H, handler interface{}) Handler
- func (g *Group) Options(path string, h interface{}, m ...interface{})
- func (g *Group) Patch(path string, h interface{}, m ...interface{})
- func (g *Group) Post(path string, h interface{}, m ...interface{})
- func (g *Group) Pre(middleware ...interface{})
- func (g *Group) PreUse(middleware ...interface{})
- func (g *Group) Prefix() string
- func (g *Group) Put(path string, h interface{}, m ...interface{})
- func (g *Group) Route(methods string, path string, h interface{}, middleware ...interface{})
- func (g *Group) SetRenderer(r Renderer)
- func (g *Group) Static(prefix, root string)
- func (g *Group) Trace(path string, h interface{}, m ...interface{})
- func (g *Group) URL(h interface{}, params ...interface{}) string
- func (g *Group) Use(middleware ...interface{})
- type H
- type HTTPError
- type HTTPErrorHandler
- type Handler
- type HandlerFunc
- type ICore
- type KV
- type KVData
- func (a *KVData) Add(k, v string) *KVData
- func (a *KVData) Delete(ks ...string) *KVData
- func (a *KVData) Get(k string) string
- func (a *KVData) Has(k string) bool
- func (a *KVData) Index(k string) []int
- func (a *KVData) Indexes() map[string][]int
- func (a *KVData) Reset() *KVData
- func (a *KVData) Set(k, v string) *KVData
- func (a *KVData) Slice() []*KV
- type KVList
- type Mapx
- func (m *Mapx) Add(name string, values []string) *Mapx
- func (m *Mapx) Clone() *Mapx
- func (m *Mapx) Get(names ...string) *Mapx
- func (m *Mapx) Parse(data map[string][]string, keySkipper ...func(string) bool) *Mapx
- func (m *Mapx) Value(names ...string) string
- func (m *Mapx) ValueOk(names ...string) (string, bool)
- func (m *Mapx) Values(names ...string) []string
- func (m *Mapx) ValuesOk(names ...string) ([]string, bool)
- type Meta
- type MetaHandler
- type Middleware
- func WrapMiddleware(m interface{}) Middleware
- func WrapMiddlewareFromHandler(h HandlerFunc) Middleware
- func WrapMiddlewareFromStdHandleFunc(h func(http.ResponseWriter, *http.Request)) Middleware
- func WrapMiddlewareFromStdHandleFuncd(h func(http.ResponseWriter, *http.Request) error) Middleware
- func WrapMiddlewareFromStdHandler(h http.Handler) Middleware
- type MiddlewareFunc
- type MiddlewareFuncd
- type MiddlewareRegister
- type Name
- type NopSession
- func (n *NopSession) AddFlash(_ interface{}, _ ...string) Sessioner
- func (n *NopSession) Clear() Sessioner
- func (n *NopSession) Delete(name string) Sessioner
- func (n *NopSession) Flashes(_ ...string) []interface{}
- func (n *NopSession) Get(name string) interface{}
- func (n *NopSession) ID() string
- func (n *NopSession) Options(_ SessionOptions) Sessioner
- func (n *NopSession) Save() error
- func (n *NopSession) Set(name string, value interface{}) Sessioner
- func (n *NopSession) SetID(id string) Sessioner
- type NopTranslate
- type NopValidation
- type PanicError
- func (p *PanicError) AddTrace(trace *Trace) *PanicError
- func (p *PanicError) Debug() bool
- func (p *PanicError) Error() string
- func (p *PanicError) ExtractSnippets(file string, curLineNum int, index int) error
- func (p *PanicError) HTML() template.HTML
- func (p *PanicError) JSONString() string
- func (p *PanicError) SetDebug(on bool) *PanicError
- func (p *PanicError) SetError(err error) *PanicError
- func (p *PanicError) SetErrorString(errStr string) *PanicError
- func (p *PanicError) String() string
- type Prefixer
- type RawData
- func (d *RawData) Assign(key string, val interface{})
- func (d *RawData) Assignx(values *map[string]interface{})
- func (d *RawData) Error() string
- func (d *RawData) GetCode() State
- func (d *RawData) GetData() interface{}
- func (d *RawData) GetInfo() interface{}
- func (d *RawData) GetZone() interface{}
- func (d *RawData) Gets() (State, interface{}, interface{}, interface{})
- func (d *RawData) Reset() Data
- func (d *RawData) Set(code int, args ...interface{}) Data
- func (d *RawData) SetCode(code int) Data
- func (d *RawData) SetContext(ctx Context) Data
- func (d *RawData) SetData(data interface{}, args ...int) Data
- func (d *RawData) SetError(err error, args ...int) Data
- func (d *RawData) SetInfo(info interface{}, args ...int) Data
- func (d *RawData) SetTmplFuncs()
- func (d *RawData) SetZone(zone interface{}) Data
- func (d *RawData) String() string
- type Renderer
- type Route
- type RouteRegister
- type Router
- type SessionOptions
- type Sessioner
- type Skipper
- type Snippet
- type SnippetGroup
- type State
- type Status
- type Store
- func (s Store) Bool(key string, defaults ...interface{}) bool
- func (s Store) CSS(key string, defaults ...interface{}) template.CSS
- func (s Store) Decr(key string, n int64, defaults ...interface{}) int64
- func (s Store) Delete(keys ...string)
- func (s Store) Float32(key string, defaults ...interface{}) float32
- func (s Store) Float64(key string, defaults ...interface{}) float64
- func (s Store) Get(key string, defaults ...interface{}) interface{}
- func (s Store) HTML(key string, defaults ...interface{}) template.HTML
- func (s Store) HTMLAttr(key string, defaults ...interface{}) template.HTMLAttr
- func (s Store) Incr(key string, n int64, defaults ...interface{}) int64
- func (s Store) Int(key string, defaults ...interface{}) int
- func (s Store) Int16(key string, defaults ...interface{}) int16
- func (s Store) Int32(key string, defaults ...interface{}) int32
- func (s Store) Int64(key string, defaults ...interface{}) int64
- func (s Store) Int8(key string, defaults ...interface{}) int8
- func (s Store) JS(key string, defaults ...interface{}) template.JS
- func (s Store) Set(key string, value interface{}) Store
- func (s Store) String(key string, defaults ...interface{}) string
- func (s Store) Uint(key string, defaults ...interface{}) uint
- func (s Store) Uint16(key string, defaults ...interface{}) uint16
- func (s Store) Uint32(key string, defaults ...interface{}) uint32
- func (s Store) Uint64(key string, defaults ...interface{}) uint64
- func (s Store) Uint8(key string, defaults ...interface{}) uint8
- type ToConversion
- type Trace
- type Translator
- type URLBuilder
- type ValidateResult
- type Validation
- type Validator
- type ValidatorResult
- func (v *ValidatorResult) Error() error
- func (v *ValidatorResult) Field() string
- func (v *ValidatorResult) Ok() bool
- func (v *ValidatorResult) Raw() interface{}
- func (v *ValidatorResult) SetError(err error) ValidateResult
- func (v *ValidatorResult) SetField(field string) ValidateResult
- func (v *ValidatorResult) SetRaw(raw interface{}) ValidateResult
Constants ¶
const ( // CONNECT HTTP method CONNECT = "CONNECT" // DELETE HTTP method DELETE = "DELETE" // GET HTTP method GET = "GET" // HEAD HTTP method HEAD = "HEAD" // OPTIONS HTTP method OPTIONS = "OPTIONS" // PATCH HTTP method PATCH = "PATCH" // POST HTTP method POST = "POST" // PUT HTTP method PUT = "PUT" // TRACE HTTP method TRACE = "TRACE" MIMEApplicationJSON = "application/json" MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + CharsetUTF8 MIMEApplicationJavaScript = "application/javascript" MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + CharsetUTF8 MIMEApplicationXML = "application/xml" MIMEApplicationXMLCharsetUTF8 = MIMEApplicationXML + "; " + CharsetUTF8 MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEApplicationProtobuf = "application/protobuf" MIMEApplicationMsgpack = "application/msgpack" MIMETextHTML = "text/html" MIMETextHTMLCharsetUTF8 = MIMETextHTML + "; " + CharsetUTF8 MIMETextPlain = "text/plain" MIMETextPlainCharsetUTF8 = MIMETextPlain + "; " + CharsetUTF8 MIMEMultipartForm = "multipart/form-data" MIMEOctetStream = "application/octet-stream" MIMEEventStream = "text/event-stream" CharsetUTF8 = "charset=utf-8" HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" HeaderAllow = "Allow" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderIfModifiedSince = "If-Modified-Since" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXForwardedFor = "X-Forwarded-For" HeaderXRealIP = "X-Real-IP" HeaderXRequestID = "X-Request-ID" HeaderXRequestedWith = "X-Requested-With" HeaderServer = "Server" HeaderOrigin = "Origin" HeaderCacheControl = "Cache-Control" // Access control HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" // Security HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXXSSProtection = "X-XSS-Protection" HeaderXFrameOptions = "X-Frame-Options" HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderXCSRFToken = "X-CSRF-Token" FilePathSeparator = string(filepath.Separator) )
const SnippetLineNumbers = 13
Variables ¶
var ( //DefaultNopFilter 默认过滤器(map->struct) DefaultNopFilter FormDataFilter = func(k string, v []string) (string, []string) { return k, v } //DefaultFieldNameFormatter 默认格式化函数(struct->form) DefaultFieldNameFormatter FieldNameFormatter = func(topName, fieldName string) string { var fName string if len(topName) == 0 { fName = fieldName } else { fName = topName + "." + fieldName } return fName } //LowerCaseFirstLetter 小写首字母(struct->form) LowerCaseFirstLetter FieldNameFormatter = func(topName, fieldName string) string { var fName string s := []rune(fieldName) if len(s) > 0 { s[0] = unicode.ToLower(s[0]) fieldName = string(s) } if len(topName) == 0 { fName = fieldName } else { fName = topName + "." + fieldName } return fName } )
var ( //States 状态码对应的文本 States = map[State]*Status{ -2: {`Non-Privileged`, http.StatusOK}, -1: {`Unauthenticated`, http.StatusOK}, 0: {`Failure`, http.StatusOK}, 1: {`Success`, http.StatusOK}, } //GetStatus 获取状态值 GetStatus = func(key State) (*Status, bool) { v, y := States[key] return v, y } )
var ( DefaultNopSession Sessioner = &NopSession{} DefaultDebugSession Sessioner = &DebugSession{} DefaultSession = DefaultNopSession DefaultSessionOptions = &SessionOptions{ Engine: `cookie`, Name: `SID`, CookieOptions: &CookieOptions{ Path: `/`, }, } )
var ( ErrUnsupportedMediaType error = NewHTTPError(http.StatusUnsupportedMediaType) ErrNotFound error = NewHTTPError(http.StatusNotFound) ErrForbidden error = NewHTTPError(http.StatusForbidden) ErrStatusRequestEntityTooLarge error = NewHTTPError(http.StatusRequestEntityTooLarge) ErrMethodNotAllowed error = NewHTTPError(http.StatusMethodNotAllowed) ErrRendererNotRegistered = errors.New("renderer not registered") ErrInvalidRedirectCode = errors.New("invalid redirect status code") NotFoundHandler = HandlerFunc(func(c Context) error { return ErrNotFound }) MethodNotAllowedHandler = HandlerFunc(func(c Context) error { return ErrMethodNotAllowed }) )
var DefaultHTMLFilter = func(v string) (r string) {
return v
}
DefaultHTMLFilter html filter (`form_filter:"html"`)
Functions ¶
func CaptureTokens ¶ added in v1.3.5
func ContentTypeByExtension ¶
ContentTypeByExtension returns the MIME type associated with the file based on its extension. It returns `application/octet-stream` incase MIME type is not found.
func DefaultSkipper ¶
DefaultSkipper returns false which processes the middleware.
func HandlerPath ¶ added in v1.3.7
func HandlerPath(h interface{}) string
HandlerPath returns the handler path
func HandlerTmpl ¶ added in v1.3.7
func NamedStructMap ¶
func NamedStructMap(e *Echo, m interface{}, data map[string][]string, topName string, filters ...FormDataFilter) error
NamedStructMap 自动将map值映射到结构体
func StructToForm ¶ added in v1.1.0
func StructToForm(ctx Context, m interface{}, topName string, fieldNameFormatter FieldNameFormatter)
StructToForm 映射struct到form
Types ¶
type Binder ¶
type Binder interface {
Bind(interface{}, Context, ...FormDataFilter) error
MustBind(interface{}, Context, ...FormDataFilter) error
}
Binder is the interface that wraps the Bind method.
type Context ¶
type Context interface {
context.Context
events.Emitter
SetEmitter(events.Emitter)
StdContext() context.Context
SetStdContext(context.Context)
Validator
SetValidator(Validator)
Translator
SetTranslator(Translator)
Request() engine.Request
Response() engine.Response
Handle(Context) error
Logger() logger.Logger
Object() *xContext
Echo() *Echo
Route() *Route
Reset(engine.Request, engine.Response)
Path() string
P(int, ...string) string
Param(string, ...string) string
// ParamNames returns path parameter names.
ParamNames() []string
ParamValues() []string
SetParamValues(values ...string)
// Queries returns the query parameters as map. It is an alias for `engine.URL#Query()`.
Queries() map[string][]string
QueryValues(string) []string
QueryxValues(string) param.StringSlice
Query(string, ...string) string
Form(string, ...string) string
FormValues(string) []string
FormxValues(string) param.StringSlice
// Forms returns the form parameters as map. It is an alias for `engine.Request#Form().All()`.
Forms() map[string][]string
// Param+
Px(int, ...string) param.String
Paramx(string, ...string) param.String
Queryx(string, ...string) param.String
Formx(string, ...string) param.String
// string to param.String
Atop(string) param.String
ToParamString(string) param.String
ToStringSlice([]string) param.StringSlice
Set(string, interface{})
Get(string, ...interface{}) interface{}
Delete(...string)
Stored() Store
Bind(interface{}, ...FormDataFilter) error
MustBind(interface{}, ...FormDataFilter) error
Render(string, interface{}, ...int) error
HTML(string, ...int) error
String(string, ...int) error
Blob([]byte, ...int) error
JSON(interface{}, ...int) error
JSONBlob([]byte, ...int) error
JSONP(string, interface{}, ...int) error
XML(interface{}, ...int) error
XMLBlob([]byte, ...int) error
Stream(func(io.Writer) bool)
SSEvent(string, chan interface{}) error
File(string, ...http.FileSystem) error
Attachment(io.ReadSeeker, string) error
NoContent(...int) error
Redirect(string, ...int) error
Error(err error)
SetCode(int)
Code() int
SetData(Data)
Data() Data
// ServeContent sends static content from `io.Reader` and handles caching
// via `If-Modified-Since` request header. It automatically sets `Content-Type`
// and `Last-Modified` response headers.
ServeContent(io.ReadSeeker, string, time.Time) error
SetFunc(string, interface{})
GetFunc(string) interface{}
ResetFuncs(map[string]interface{})
Funcs() map[string]interface{}
PrintFuncs()
//----------------
// Render
//----------------
SetAuto(on bool) Context
Fetch(string, interface{}) ([]byte, error)
SetRenderer(Renderer)
SetCookieOptions(*CookieOptions)
CookieOptions() *CookieOptions
NewCookie(string, string) *Cookie
Cookie() Cookier
GetCookie(string) string
SetCookie(string, string, ...interface{})
SetSessionOptions(*SessionOptions)
SessionOptions() *SessionOptions
SetSessioner(Sessioner)
Session() Sessioner
Flash(...string) interface{}
Header(string) string
IsAjax() bool
IsPjax() bool
PjaxContainer() string
Method() string
Format() string
SetFormat(string)
IsPost() bool
IsGet() bool
IsPut() bool
IsDel() bool
IsHead() bool
IsPatch() bool
IsOptions() bool
IsSecure() bool
IsWebsocket() bool
IsUpload() bool
ResolveContentType() string
WithFormatExtension(bool)
ResolveFormat() string
Accept() *Accept
Protocol() string
Site() string
Scheme() string
Domain() string
Host() string
Proxy() []string
Referer() string
Port() int
RealIP() string
HasAnyRequest() bool
MapForm(i interface{}, names ...string) error
MapData(i interface{}, data map[string][]string, names ...string) error
SaveUploadedFile(fieldName string, saveAbsPath string, saveFileName ...string) (*multipart.FileHeader, error)
SaveUploadedFileToWriter(string, io.Writer) (*multipart.FileHeader, error)
//Multiple file upload
SaveUploadedFiles(fieldName string, savePath func(*multipart.FileHeader) string) error
SaveUploadedFilesToWriter(fieldName string, writer func(*multipart.FileHeader) io.Writer) error
AddPreResponseHook(func() error) Context
SetPreResponseHook(...func() error) Context
}
Context represents context for the current request. It holds request and response objects, path parameters, data and registered handler.
type ContextRegister ¶ added in v1.3.5
type ContextRegister interface {
SetContext(Context)
}
type Cookie ¶
type Cookie struct {
// contains filtered or unexported fields
}
Cookie 操作封装
type CookieOptions ¶
type CookieOptions struct {
Prefix string
// MaxAge=0 means no 'Max-Age' attribute specified.
// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'.
// MaxAge>0 means Max-Age attribute present and given in seconds.
MaxAge int
Path string
Domain string
Secure bool
HttpOnly bool
}
CookieOptions cookie options
func (*CookieOptions) Clone ¶ added in v1.3.0
func (c *CookieOptions) Clone() *CookieOptions
type Cookier ¶
type Cookier interface {
Get(key string) string
Set(key string, val string, args ...interface{}) Cookier
}
Cookier interface
type Data ¶
type Data interface {
Assign(key string, val interface{})
Assignx(values *map[string]interface{})
SetTmplFuncs()
SetContext(ctx Context) Data
String() string
Set(code int, args ...interface{}) Data
Reset() Data
SetError(err error, args ...int) Data
SetCode(code int) Data
SetInfo(info interface{}, args ...int) Data
SetZone(zone interface{}) Data
SetData(data interface{}, args ...int) Data
Gets() (code State, info interface{}, zone interface{}, data interface{})
GetCode() State
GetInfo() interface{}
GetZone() interface{}
GetData() interface{}
}
Data 响应数据
type DebugSession ¶ added in v1.3.5
type DebugSession struct {
}
func (*DebugSession) AddFlash ¶ added in v1.3.5
func (n *DebugSession) AddFlash(value interface{}, args ...string) Sessioner
func (*DebugSession) Clear ¶ added in v1.3.5
func (n *DebugSession) Clear() Sessioner
func (*DebugSession) Delete ¶ added in v1.3.5
func (n *DebugSession) Delete(name string) Sessioner
func (*DebugSession) Flashes ¶ added in v1.3.5
func (n *DebugSession) Flashes(args ...string) []interface{}
func (*DebugSession) Get ¶ added in v1.3.5
func (n *DebugSession) Get(name string) interface{}
func (*DebugSession) ID ¶ added in v1.3.5
func (n *DebugSession) ID() string
func (*DebugSession) Options ¶ added in v1.3.5
func (n *DebugSession) Options(options SessionOptions) Sessioner
func (*DebugSession) Save ¶ added in v1.3.5
func (n *DebugSession) Save() error
func (*DebugSession) Set ¶ added in v1.3.5
func (n *DebugSession) Set(name string, value interface{}) Sessioner
func (*DebugSession) SetID ¶ added in v1.3.5
func (n *DebugSession) SetID(id string) Sessioner
type Echo ¶
type Echo struct {
FuncMap map[string]interface{}
RouteDebug bool
MiddlewareDebug bool
JSONPVarName string
// contains filtered or unexported fields
}
func NewWithContext ¶
func (*Echo) AddAcceptFormat ¶ added in v1.3.0
func (*Echo) AddFormatRenderer ¶ added in v1.3.7
func (*Echo) AddHandlerWrapper ¶ added in v1.1.0
func (*Echo) AddMiddlewareWrapper ¶ added in v1.1.0
func (e *Echo) AddMiddlewareWrapper(funcs ...func(interface{}) Middleware)
func (*Echo) Clear ¶ added in v1.3.0
func (e *Echo) Clear(middleware ...interface{})
Clear middleware
func (*Echo) DefaultHTTPErrorHandler ¶
DefaultHTTPErrorHandler invokes the default HTTP error handler.
func (*Echo) HTTPErrorHandler ¶ added in v1.3.0
func (e *Echo) HTTPErrorHandler() HTTPErrorHandler
HTTPErrorHandler returns the HTTPErrorHandler
func (*Echo) MetaHandler ¶
MetaHandler Add meta information about endpoint
func (*Echo) NamedRoutes ¶
NamedRoutes returns the registered handler name.
func (*Echo) Pre ¶
func (e *Echo) Pre(middleware ...interface{})
Pre is an alias for `PreUse` function.
func (*Echo) PreUse ¶
func (e *Echo) PreUse(middleware ...interface{})
PreUse adds handler to the middleware chain.
func (*Echo) RebuildRouter ¶
RebuildRouter rebuild router
func (*Echo) RemoveFormatRenderer ¶ added in v1.3.7
func (*Echo) SetAcceptFormats ¶ added in v1.3.0
func (*Echo) SetFormatRenderers ¶ added in v1.3.7
func (*Echo) SetHTTPErrorHandler ¶
func (e *Echo) SetHTTPErrorHandler(h HTTPErrorHandler)
SetHTTPErrorHandler registers a custom Echo.HTTPErrorHandler.
func (*Echo) SetHandlerWrapper ¶ added in v1.1.0
func (*Echo) SetMiddlewareWrapper ¶ added in v1.1.0
func (e *Echo) SetMiddlewareWrapper(funcs ...func(interface{}) Middleware)
func (*Echo) SetRenderer ¶
SetRenderer registers an HTML template renderer. It's invoked by Context.Render().
func (*Echo) Static ¶ added in v1.3.0
Static registers a new route with path prefix to serve static files from the provided root directory.
func (*Echo) Use ¶
func (e *Echo) Use(middleware ...interface{})
Use adds handler to the middleware chain.
func (*Echo) ValidHandler ¶
func (*Echo) ValidMiddleware ¶
func (e *Echo) ValidMiddleware(v interface{}) (m Middleware)
type FieldNameFormatter ¶ added in v1.1.0
FieldNameFormatter 结构体字段值映射到表单时,结构体字段名称格式化处理
type FormDataFilter ¶ added in v1.1.0
FormDataFilter 将map映射到结构体时,对名称和值的过滤处理,如果返回的名称为空,则跳过本字段
type FromConversion ¶
FromConversion a struct implements this interface can be convert from request param to a struct
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) MetaHandler ¶ added in v1.3.5
MetaHandler Add meta information about endpoint
func (*Group) Pre ¶
func (g *Group) Pre(middleware ...interface{})
Pre is an alias for `PreUse` function.
func (*Group) SetRenderer ¶
type H ¶
type H map[string]interface{}
func (H) MarshalXML ¶
MarshalXML allows type H to be used with xml.Marshal
type HTTPError ¶
func NewHTTPError ¶
type HTTPErrorHandler ¶
HTTPErrorHandler is a centralized HTTP error handler.
type Handler ¶
func WrapHandler ¶
func WrapHandler(h interface{}) Handler
WrapHandler wrap `interface{}` into `echo.Handler`.
type HandlerFunc ¶
func (HandlerFunc) Handle ¶
func (h HandlerFunc) Handle(c Context) error
type ICore ¶ added in v1.1.0
type ICore interface {
RouteRegister
MiddlewareRegister
URLBuilder
}
type KVData ¶ added in v1.1.1
type KVData struct {
// contains filtered or unexported fields
}
KVData 键值对数据(保持顺序)
type Mapx ¶ added in v1.1.1
type Mapx struct {
Map map[string]*Mapx `json:",omitempty"`
Slice []*Mapx `json:",omitempty"`
Val []string `json:",omitempty"`
// contains filtered or unexported fields
}
type MetaHandler ¶ added in v1.3.0
type MetaHandler struct {
Handler
// contains filtered or unexported fields
}
func (*MetaHandler) Meta ¶ added in v1.3.0
func (m *MetaHandler) Meta() H
func (*MetaHandler) Name ¶ added in v1.3.5
func (m *MetaHandler) Name() string
type Middleware ¶
func WrapMiddleware ¶
func WrapMiddleware(m interface{}) Middleware
WrapMiddleware wrap `interface{}` into `echo.Middleware`.
func WrapMiddlewareFromHandler ¶
func WrapMiddlewareFromHandler(h HandlerFunc) Middleware
WrapMiddlewareFromHandler wrap `echo.HandlerFunc` into `echo.Middleware`.
func WrapMiddlewareFromStdHandleFunc ¶
func WrapMiddlewareFromStdHandleFunc(h func(http.ResponseWriter, *http.Request)) Middleware
WrapMiddlewareFromStdHandleFunc wrap `func(http.ResponseWriter, *http.Request)` into `echo.Middleware`.
func WrapMiddlewareFromStdHandleFuncd ¶
func WrapMiddlewareFromStdHandleFuncd(h func(http.ResponseWriter, *http.Request) error) Middleware
WrapMiddlewareFromStdHandleFuncd wrap `func(http.ResponseWriter, *http.Request)` into `echo.Middleware`.
func WrapMiddlewareFromStdHandler ¶
func WrapMiddlewareFromStdHandler(h http.Handler) Middleware
WrapMiddlewareFromStdHandler wrap `http.HandlerFunc` into `echo.Middleware`.
type MiddlewareFunc ¶
func (MiddlewareFunc) Handle ¶
func (m MiddlewareFunc) Handle(h Handler) Handler
type MiddlewareFuncd ¶
type MiddlewareFuncd func(Handler) HandlerFunc
func (MiddlewareFuncd) Handle ¶
func (m MiddlewareFuncd) Handle(h Handler) Handler
type MiddlewareRegister ¶ added in v1.1.0
type MiddlewareRegister interface {
Use(middleware ...interface{})
Pre(middleware ...interface{})
}
type NopSession ¶
type NopSession struct {
}
func (*NopSession) AddFlash ¶
func (n *NopSession) AddFlash(_ interface{}, _ ...string) Sessioner
func (*NopSession) Clear ¶
func (n *NopSession) Clear() Sessioner
func (*NopSession) Delete ¶
func (n *NopSession) Delete(name string) Sessioner
func (*NopSession) Flashes ¶
func (n *NopSession) Flashes(_ ...string) []interface{}
func (*NopSession) Get ¶
func (n *NopSession) Get(name string) interface{}
func (*NopSession) ID ¶ added in v1.3.0
func (n *NopSession) ID() string
func (*NopSession) Options ¶
func (n *NopSession) Options(_ SessionOptions) Sessioner
func (*NopSession) Save ¶
func (n *NopSession) Save() error
func (*NopSession) Set ¶
func (n *NopSession) Set(name string, value interface{}) Sessioner
func (*NopSession) SetID ¶ added in v1.3.0
func (n *NopSession) SetID(id string) Sessioner
type NopTranslate ¶
type NopTranslate struct {
// contains filtered or unexported fields
}
func (*NopTranslate) Lang ¶
func (n *NopTranslate) Lang() string
func (*NopTranslate) T ¶
func (n *NopTranslate) T(format string, args ...interface{}) string
type NopValidation ¶ added in v1.2.0
type NopValidation struct {
}
func (*NopValidation) Validate ¶ added in v1.2.0
func (v *NopValidation) Validate(_ interface{}, _ ...string) ValidateResult
type PanicError ¶ added in v1.3.0
type PanicError struct {
Raw interface{}
Traces []*Trace
Snippets []*SnippetGroup
// contains filtered or unexported fields
}
func NewPanicError ¶ added in v1.3.0
func NewPanicError(recovered interface{}, err error) *PanicError
func (*PanicError) AddTrace ¶ added in v1.3.0
func (p *PanicError) AddTrace(trace *Trace) *PanicError
func (*PanicError) Debug ¶ added in v1.3.0
func (p *PanicError) Debug() bool
func (*PanicError) Error ¶ added in v1.3.0
func (p *PanicError) Error() string
func (*PanicError) ExtractSnippets ¶ added in v1.3.0
func (p *PanicError) ExtractSnippets(file string, curLineNum int, index int) error
func (*PanicError) HTML ¶ added in v1.3.0
func (p *PanicError) HTML() template.HTML
func (*PanicError) JSONString ¶ added in v1.3.0
func (p *PanicError) JSONString() string
func (*PanicError) SetDebug ¶ added in v1.3.0
func (p *PanicError) SetDebug(on bool) *PanicError
func (*PanicError) SetError ¶ added in v1.3.0
func (p *PanicError) SetError(err error) *PanicError
func (*PanicError) SetErrorString ¶ added in v1.3.0
func (p *PanicError) SetErrorString(errStr string) *PanicError
func (*PanicError) String ¶ added in v1.3.0
func (p *PanicError) String() string
type RawData ¶ added in v1.3.0
type RawData struct {
Code State
State string `json:",omitempty" xml:",omitempty"`
Info interface{}
Zone interface{} `json:",omitempty" xml:",omitempty"`
Data interface{} `json:",omitempty" xml:",omitempty"`
// contains filtered or unexported fields
}
func (*RawData) SetContext ¶ added in v1.3.0
SetContext 设置Context
type Route ¶
type RouteRegister ¶ added in v1.1.0
type RouteRegister interface {
Any(path string, h interface{}, middleware ...interface{})
Route(methods string, path string, h interface{}, middleware ...interface{})
Match(methods []string, path string, h interface{}, middleware ...interface{})
Connect(path string, h interface{}, m ...interface{})
Delete(path string, h interface{}, m ...interface{})
Get(path string, h interface{}, m ...interface{})
Head(path string, h interface{}, m ...interface{})
Options(path string, h interface{}, m ...interface{})
Patch(path string, h interface{}, m ...interface{})
Post(path string, h interface{}, m ...interface{})
Put(path string, h interface{}, m ...interface{})
Trace(path string, h interface{}, m ...interface{})
Static(prefix, root string)
File(path, file string)
}
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
type SessionOptions ¶
type SessionOptions struct {
Engine string //Store Engine
Name string //Session Name
*CookieOptions
}
SessionOptions stores configuration for a session or session store. Fields are a subset of http.Cookie fields.
func (*SessionOptions) Clone ¶ added in v1.3.0
func (s *SessionOptions) Clone() *SessionOptions
type Sessioner ¶
type Sessioner interface {
// Get returns the session value associated to the given key.
Get(key string) interface{}
// Set sets the session value associated to the given key.
Set(key string, val interface{}) Sessioner
SetID(id string) Sessioner
ID() string
// Delete removes the session value associated to the given key.
Delete(key string) Sessioner
// Clear deletes all values in the session.
Clear() Sessioner
// AddFlash adds a flash message to the session.
// A single variadic argument is accepted, and it is optional: it defines the flash key.
// If not defined "_flash" is used by default.
AddFlash(value interface{}, vars ...string) Sessioner
// Flashes returns a slice of flash messages from the session.
// A single variadic argument is accepted, and it is optional: it defines the flash key.
// If not defined "_flash" is used by default.
Flashes(vars ...string) []interface{}
// Save saves all sessions used during the current request.
Save() error
}
Sessioner Wraps thinly gorilla-session methods. Session stores the values and optional configuration for a session.
type Skipper ¶
Skipper defines a function to skip middleware. Returning true skips processing the middleware.
type SnippetGroup ¶ added in v1.3.0
func (*SnippetGroup) String ¶ added in v1.3.0
func (sg *SnippetGroup) String() string
func (*SnippetGroup) TableRow ¶ added in v1.3.0
func (sg *SnippetGroup) TableRow() string
type Store ¶ added in v1.3.7
type Store map[string]interface{}
type ToConversion ¶
type ToConversion interface {
ToString() string
}
ToConversion a struct implements this interface can be convert from struct to template variable Not Implemented
type Translator ¶
var DefaultNopTranslate Translator = &NopTranslate{language: `en`}
type URLBuilder ¶ added in v1.1.0
type URLBuilder interface {
URL(interface{}, ...interface{}) string
}
type ValidateResult ¶ added in v1.3.0
type ValidateResult interface {
Ok() bool
Error() error
Field() string
Raw() interface{}
//setter
SetError(error) ValidateResult
SetField(string) ValidateResult
SetRaw(interface{}) ValidateResult
}
func NewValidateResult ¶ added in v1.3.0
func NewValidateResult() ValidateResult
type Validation ¶ added in v1.2.0
type Validation struct {
// contains filtered or unexported fields
}
func (*Validation) Validate ¶ added in v1.2.0
func (v *Validation) Validate(i interface{}, args ...string) ValidateResult
Validate 此处支持两种用法: 1. Validate(表单字段名, 表单值, 验证规则名) 2. Validate(结构体实例, 要验证的结构体字段1,要验证的结构体字段2) Validate(结构体实例) 代表验证所有带“valid”标签的字段
type Validator ¶
type Validator interface {
Validate(i interface{}, args ...string) ValidateResult
}
Validator is the interface that wraps the Validate method.
var ( DefaultNopValidate Validator = &NopValidation{} ErrNoSetValidator = errors.New(`The validator is not set`) )
func NewValidation ¶ added in v1.2.0
func NewValidation() Validator
type ValidatorResult ¶ added in v1.3.0
type ValidatorResult struct {
// contains filtered or unexported fields
}
func (*ValidatorResult) Error ¶ added in v1.3.0
func (v *ValidatorResult) Error() error
func (*ValidatorResult) Field ¶ added in v1.3.0
func (v *ValidatorResult) Field() string
func (*ValidatorResult) Ok ¶ added in v1.3.0
func (v *ValidatorResult) Ok() bool
func (*ValidatorResult) Raw ¶ added in v1.3.0
func (v *ValidatorResult) Raw() interface{}
func (*ValidatorResult) SetError ¶ added in v1.3.0
func (v *ValidatorResult) SetError(err error) ValidateResult
func (*ValidatorResult) SetField ¶ added in v1.3.0
func (v *ValidatorResult) SetField(field string) ValidateResult
func (*ValidatorResult) SetRaw ¶ added in v1.3.0
func (v *ValidatorResult) SetRaw(raw interface{}) ValidateResult
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding
|
|
|
handler
|
|
|
mvc/static/minify
Package cssmin minifies CSS.
|
Package cssmin minifies CSS. |
|
mvc/test
command
|
|
|
oauth2/example
command
|
|
|
sockjs/example
command
|
|
|
websocket/example
command
|
|
|
markdown/example
command
|
|
|
ratelimit/config
Package config provides data structure to configure rate-limiter.
|
Package config provides data structure to configure rate-limiter. |
|
ratelimit/test
command
|
|
|
render/example
command
|
|
|
render/jet/test
command
|
|
|
render/pongo2/test
command
|
|
|
render/sse/test
command
|
|
|
render/standard
* * 模板扩展 * @author swh <swh@admpub.com>
|
* * 模板扩展 * @author swh <swh@admpub.com> |
|
render/standard/test
command
|
|
|
session/test
command
|
|