Documentation ¶
Index ¶
- Constants
- Variables
- func AddListener(listener events.Listener, names ...string) events.Emitterer
- func AsStdContext(eCtx Context) context.Context
- func Bool(key interface{}, defaults ...interface{}) bool
- func CSS(key interface{}, defaults ...interface{}) template.CSS
- func CaptureTokens(pattern *regexp.Regexp, input string) *strings.Replacer
- func CaptureTokensByValues(values []string, kv map[string]string, quoted ...bool) *strings.Replacer
- func Clear(old []interface{}, clears ...interface{}) []interface{}
- func ContentTypeByExtension(name string) (t string)
- func CookieExpires(stdCookie *http.Cookie, expires time.Time)
- func CookieMaxAge(stdCookie *http.Cookie, p int)
- func CookieSameSite(stdCookie *http.Cookie, p string)
- func CopyCookieOptions(from *http.Cookie, to *http.Cookie)
- func DateTime(key interface{}, layouts ...string) time.Time
- func Decr(key interface{}, n int64, defaults ...interface{}) int64
- func DefaultRenderDataWrapper(ctx Context, data interface{}) interface{}
- func DefaultSkipper(c Context) bool
- func Delete(key interface{})
- func DetectError(c Context, err error) error
- func Dump(m interface{}, printOrNot ...bool) (r string)
- func E(format string, args ...interface{}) error
- func EventNames() []string
- func Fire(e interface{}) error
- func FireByName(name string, options ...events.EventOption) error
- func FireByNameWithMap(name string, data events.Map) error
- func FlatStructToForm(ctx Context, m interface{}, fieldNameFormatter FieldNameFormatter, ...)
- func Float32(key interface{}, defaults ...interface{}) float32
- func Float64(key interface{}, defaults ...interface{}) float64
- func FormNames(s string) []string
- func FormToMap(e *Echo, m interface{}, data map[string][]string, topName string, ...) error
- func FormToMapWithDecoder(e *Echo, m interface{}, data map[string][]string, topName string, ...) error
- func FormToStruct(e *Echo, m interface{}, data map[string][]string, topName string, ...) error
- func FormToStructWithDecoder(e *Echo, m interface{}, data map[string][]string, topName string, ...) error
- func Get(key interface{}, defaults ...interface{}) interface{}
- func GetNextURL(ctx Context, varNames ...string) string
- func GetOk(key interface{}) (interface{}, bool)
- func GetOrSet(key, value interface{}) (actual interface{}, loaded bool)
- func GetOtherURL(ctx Context, next string) string
- func GetValidated(c Context, defaults ...interface{}) interface{}
- func HTML(key interface{}, defaults ...interface{}) template.HTML
- func HTMLAttr(key interface{}, defaults ...interface{}) template.HTMLAttr
- func HandlerName(h interface{}) string
- func HandlerPath(h interface{}) string
- func HandlerTmpl(handlerPath string) string
- func Has(key interface{}) bool
- func HasEvent(name string) bool
- func InErrorCode(err error, codes ...pkgCode.Code) bool
- func InSliceFold(value string, items []string) bool
- func Incr(key interface{}, n int64, defaults ...interface{}) int64
- func Int(key interface{}, defaults ...interface{}) int
- func Int16(key interface{}, defaults ...interface{}) int16
- func Int32(key interface{}, defaults ...interface{}) int32
- func Int64(key interface{}, defaults ...interface{}) int64
- func Int8(key interface{}, defaults ...interface{}) int8
- func InterfacesToStrings(args []interface{}) []string
- func IsContext(t reflect.Type) bool
- func IsErrorCode(err error, code pkgCode.Code) bool
- func JS(key interface{}, defaults ...interface{}) template.JS
- func LogIf(err error, types ...string)
- func Methods() []string
- func MustGetValidated[T any](c Context) (*T, error)
- func MustValidated[T any](c Context, v T) error
- func NamedStructMap(e *Echo, m interface{}, data map[string][]string, topName string, ...) error
- func NamedStructMapWithDecoder(e *Echo, m interface{}, data map[string][]string, topName string, ...) error
- func NewCookie(key, value string, opt *CookieOptions) *http.Cookie
- func NewEvent(data interface{}, options ...events.EventOption) events.Event
- func NewHost(name string) *host
- func Off(name string) events.Emitterer
- func On(name string, handlers ...events.Listener) events.Emitterer
- func OnCallback(name string, cb func(events.Event) error, id ...string) events.Emitterer
- func OnStream(name string, ch chan events.Event, id ...string) events.Emitterer
- func PanicIf(err error)
- func ParseURIRegExp(uriRegexp string, dflRegexp string) (names []string, format string, regExp *regexp.Regexp)
- func Range(f func(key, value interface{}) bool)
- func RemoveListener(listener events.Listener) events.Emitterer
- func ReturnToCurrentURL(ctx Context, varNames ...string) string
- func SafeGetFieldByName(value reflect.Value, name string) (v reflect.Value)
- func SearchEngineNoindex(c Context)
- func Set(key, value interface{})
- func SetAttachmentHeader(c Context, name string, setContentType bool, inline ...bool)
- func SetFormValue(f engine.URLValuer, fName string, index int, value interface{})
- func SetFormValues(f engine.URLValuer, fName string, values []string)
- func SetReflectValue(source interface{}, dest reflect.Value) bool
- func SetWorkDir(dir string)
- func Split(key interface{}, sep string, limit ...int) param.StringSlice
- func String(key interface{}, defaults ...interface{}) string
- func StructToForm(ctx Context, m interface{}, topName string, ...)
- func T(format string, args ...interface{}) string
- func Timestamp(key interface{}, defaults ...interface{}) time.Time
- func ToStdContext(ctx context.Context, eCtx Context) context.Context
- func TranslateStringer(t Translator, args ...interface{}) param.Stringer
- func Trim(key interface{}, defaults ...interface{}) param.String
- func URLDecode(encoded string, rfc ...bool) (string, error)
- func URLEncode(s string, rfc ...bool) string
- func Uint(key interface{}, defaults ...interface{}) uint
- func Uint16(key interface{}, defaults ...interface{}) uint16
- func Uint32(key interface{}, defaults ...interface{}) uint32
- func Uint64(key interface{}, defaults ...interface{}) uint64
- func Uint8(key interface{}, defaults ...interface{}) uint8
- func Validate(c Context, item interface{}, args ...interface{}) error
- func ValidateStruct(c Context, item interface{}, args ...interface{}) error
- func Wd() string
- func WithNextURL(ctx Context, urlStr string, varNames ...string) string
- type Accept
- type AcceptQuality
- type Accepts
- type AfterValidate
- type AsMiddleware
- type BaseRequestValidator
- type BaseTransaction
- type BeforeBind
- type BeforeValidate
- type Binder
- type BinderFormTopNamer
- type BinderKeyNormalizer
- type BinderValueCustomDecoder
- type BinderValueCustomDecoders
- type BinderValueCustomEncoder
- type BinderValueCustomEncoders
- type BinderValueDecoder
- type BinderValueEncoder
- type Closer
- type Codec
- type Context
- type ContextRegister
- type ContextReseter
- type CookieCryptor
- type CookieOptions
- type Cookier
- type Data
- type DataWrapper
- type DebugSession
- func (n *DebugSession) AddFlash(value interface{}, args ...string) Sessioner
- func (n *DebugSession) AddPreSaveHook(_ func(Context) error)
- 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) MustID() string
- func (n *DebugSession) Options(options SessionOptions) Sessioner
- func (n *DebugSession) RemoveID(sessionID string) error
- func (n *DebugSession) Save() error
- func (n *DebugSession) Set(name string, value interface{}) Sessioner
- func (n *DebugSession) SetID(id string, notReload ...bool) error
- func (n *DebugSession) SetPreSaveHook(_ ...func(Context) error)
- type DebugTransaction
- type Echo
- func (e *Echo) Add(method, path string, handler interface{}, middleware ...interface{}) *Route
- func (e *Echo) AddAcceptFormat(mime, format string) *Echo
- func (e *Echo) AddBinderValueDecoder(name string, decoder BinderValueDecoder) *Echo
- func (e *Echo) AddBinderValueEncoder(name string, encoder BinderValueEncoder) *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{}) IRouter
- func (e *Echo) AppendRouter(routes []*Route) *Echo
- func (e *Echo) AutoDetectRenderFormat(c Context, data interface{}) (bool, error)
- func (e *Echo) Binder() Binder
- func (e *Echo) CallBinderValueDecoder(name string, field string, values []string, params string) (interface{}, error)
- func (e *Echo) CallBinderValueEncoder(name string, field string, value interface{}, params string) ([]string, error)
- func (e *Echo) Clear(middleware ...interface{})
- func (e *Echo) ClearPre(middleware ...interface{})
- func (e *Echo) Commit() *Echo
- func (e *Echo) Connect(path string, h interface{}, m ...interface{}) IRouter
- func (e *Echo) Debug() bool
- func (e *Echo) DefaultExtension() string
- func (e *Echo) DefaultHTTPErrorHandler(err error, c Context)
- func (e *Echo) Delete(path string, h interface{}, m ...interface{}) IRouter
- func (e *Echo) Engine() engine.Engine
- func (e *Echo) File(path, file string)
- func (e *Echo) Get(path string, h interface{}, m ...interface{}) IRouter
- func (e *Echo) GetRouteByName(name string) *Route
- func (e *Echo) GetRoutePathByName(name string) string
- func (e *Echo) Group(prefix string, m ...interface{}) *Group
- func (e *Echo) HTTPErrorHandler() HTTPErrorHandler
- func (e *Echo) Head(path string, h interface{}, m ...interface{}) IRouter
- func (e *Echo) Host(name string, m ...interface{}) *Group
- func (e *Echo) Hosts() map[string]*Host
- func (e *Echo) Logger() logger.Logger
- func (e *Echo) MakeHandler(handler interface{}, requests ...interface{}) Handler
- func (e *Echo) Match(methods []string, path string, h interface{}, middleware ...interface{}) IRouter
- func (e *Echo) MaxRequestBodySize() int
- func (e *Echo) MetaHandler(m H, handler interface{}, requests ...interface{}) Handler
- func (e *Echo) MetaHandlerWithRequest(m H, handler interface{}, request interface{}, methods ...string) Handler
- func (e *Echo) NamedRoutes() map[string][]int
- func (e *Echo) NewContext(req engine.Request, resp engine.Response) Context
- func (e *Echo) OnHostFound(onHostFound func(Context) (bool, error)) *Echo
- func (e *Echo) Options(path string, h interface{}, m ...interface{}) IRouter
- func (e *Echo) ParseHeaderAccept(on bool) *Echo
- func (e *Echo) Patch(path string, h interface{}, m ...interface{}) IRouter
- func (e *Echo) Post(path string, h interface{}, m ...interface{}) IRouter
- func (e *Echo) Pre(middleware ...interface{})
- func (e *Echo) Prefix() string
- func (e *Echo) Put(path string, h interface{}, m ...interface{}) IRouter
- func (e *Echo) RealIPConfig() *realip.Config
- func (e *Echo) RebuildRouter(args ...[]*Route) *Echo
- func (e *Echo) RemoveFormatRenderer(formats ...string) *Echo
- func (e *Echo) RenderDataWrapper() DataWrapper
- func (e *Echo) Renderer() Renderer
- func (e *Echo) Reset() *Echo
- func (e *Echo) Rewriter() Rewriter
- func (e *Echo) Route(methods string, path string, h interface{}, middleware ...interface{}) IRouter
- func (e *Echo) Router() *Router
- func (e *Echo) Routes() []*Route
- func (e *Echo) Run(eng engine.Engine, handler ...engine.Handler) error
- 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) SetDefaultExtension(ext string)
- func (e *Echo) SetFormSliceMaxIndex(max int) *Echo
- func (e *Echo) SetFormatRenderers(formatRenderers map[string]FormatRender) *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) SetMaxRequestBodySize(maxRequestBodySize int) *Echo
- func (e *Echo) SetMiddlewareWrapper(funcs ...func(interface{}) Middleware)
- func (e *Echo) SetPrefix(prefix string) *Echo
- func (e *Echo) SetRenderDataWrapper(dataWrapper DataWrapper)
- func (e *Echo) SetRenderer(r Renderer)
- func (e *Echo) SetRewriter(r Rewriter)
- func (e *Echo) SetValidator(validator Validator) *Echo
- func (e *Echo) Shutdown(ctx context.Context) error
- func (e *Echo) Static(prefix, root string)
- func (e *Echo) Stop() error
- func (e *Echo) Template(c Context, name string, data interface{}) (string, error)
- func (e *Echo) Trace(path string, h interface{}, m ...interface{}) IRouter
- func (e *Echo) TypeHost(alias string, args ...interface{}) (r TypeHost)
- 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 ErrUnwrap
- type Error
- func (e *Error) Cause() error
- func (e *Error) Clone() *Error
- func (e *Error) Delete(keys ...string) *Error
- func (e *Error) Error() string
- func (e *Error) ErrorCode() int
- func (e *Error) NoClone() *Error
- func (e *Error) Set(key string, value interface{}) *Error
- func (e *Error) SetError(err error) *Error
- func (e *Error) SetMessage(message string) *Error
- func (e *Error) SetZone(zone string) *Error
- func (e *Error) Unwrap() error
- type Event
- type FieldNameFormatter
- type FiltersGetter
- type FormDataFilter
- type FormNameFormatterGetter
- type FormatRender
- type FromConversion
- type Group
- func (g *Group) Add(method, path string, h interface{}, middleware ...interface{}) *Route
- func (g *Group) Alias(alias string) Hoster
- func (g *Group) Any(path string, h interface{}, middleware ...interface{}) IRouter
- func (g *Group) Connect(path string, h interface{}, m ...interface{}) IRouter
- func (g *Group) Delete(path string, h interface{}, m ...interface{}) IRouter
- func (g *Group) Echo() *Echo
- func (g *Group) File(path, file string)
- func (g *Group) Get(path string, h interface{}, m ...interface{}) IRouter
- func (g *Group) Group(prefix string, middleware ...interface{}) *Group
- func (g *Group) Head(path string, h interface{}, m ...interface{}) IRouter
- func (g *Group) Match(methods []string, path string, h interface{}, middleware ...interface{}) IRouter
- func (g *Group) MetaHandler(m H, handler interface{}, requests ...interface{}) Handler
- func (g *Group) Options(path string, h interface{}, m ...interface{}) IRouter
- func (g *Group) Patch(path string, h interface{}, m ...interface{}) IRouter
- func (g *Group) Post(path string, h interface{}, m ...interface{}) IRouter
- func (g *Group) Pre(middleware ...interface{})
- func (g *Group) Prefix() string
- func (g *Group) Put(path string, h interface{}, m ...interface{}) IRouter
- func (g *Group) Route(methods string, path string, h interface{}, middleware ...interface{}) IRouter
- func (g *Group) SetAlias(alias string) *Group
- func (g *Group) SetMeta(meta H) *Group
- func (g *Group) SetMetaKV(key string, value interface{}) *Group
- func (g *Group) SetRenderer(r Renderer)
- func (g *Group) Static(prefix, root string)
- func (g *Group) Trace(path string, h interface{}, m ...interface{}) IRouter
- 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 HandlerFuncWithArg
- type HandlerFuncs
- type Host
- type Hoster
- type ICore
- type IRouter
- type IsHiddenContext
- type IsValidContext
- type JSONModifer
- type KV
- func (a *KV) Fn() func(context.Context) interface{}
- func (a *KV) SetFn(fn func(context.Context) interface{}) *KV
- func (a *KV) SetH(h H) *KV
- func (a *KV) SetHKV(k string, v interface{}) *KV
- func (a *KV) SetK(k string) *KV
- func (a *KV) SetKV(k, v string) *KV
- func (a *KV) SetV(v string) *KV
- func (a *KV) SetX(x interface{}) *KV
- type KVData
- func (a *KVData) Add(k, v string, options ...KVOption) *KVData
- func (a *KVData) AddItem(item *KV) *KVData
- func (a *KVData) Delete(ks ...string) *KVData
- func (a *KVData) Get(k string, defaults ...string) string
- func (a *KVData) GetByIndex(index int, defaults ...string) string
- func (a *KVData) GetItem(k string, defaults ...func() *KV) *KV
- func (a *KVData) GetItemByIndex(index int, defaults ...func() *KV) *KV
- func (a *KVData) Has(k string) bool
- func (a *KVData) Index(k string) []int
- func (a *KVData) Indexes() map[string][]int
- func (a *KVData) Keys() []string
- func (a *KVData) Reset() *KVData
- func (a *KVData) Set(k, v string, options ...KVOption) *KVData
- func (a *KVData) SetItem(item *KV) *KVData
- func (a *KVData) Size() int
- func (a *KVData) Slice() []*KV
- type KVList
- type KVOption
- type KVx
- func (a *KVx[X, Y]) Fn() func(context.Context) Y
- func (a *KVx[X, Y]) SetFn(fn func(context.Context) Y) *KVx[X, Y]
- func (a *KVx[X, Y]) SetH(h H) *KVx[X, Y]
- func (a *KVx[X, Y]) SetHKV(k string, v interface{}) *KVx[X, Y]
- func (a *KVx[X, Y]) SetK(k string) *KVx[X, Y]
- func (a *KVx[X, Y]) SetKV(k, v string) *KVx[X, Y]
- func (a *KVx[X, Y]) SetV(v string) *KVx[X, Y]
- func (a *KVx[X, Y]) SetX(x X) *KVx[X, Y]
- type KVxData
- func (a *KVxData[X, Y]) Add(k, v string, options ...KVxOption[X, Y]) *KVxData[X, Y]
- func (a *KVxData[X, Y]) AddItem(item *KVx[X, Y]) *KVxData[X, Y]
- func (a *KVxData[X, Y]) Delete(ks ...string) *KVxData[X, Y]
- func (a *KVxData[X, Y]) Get(k string, defaults ...string) string
- func (a *KVxData[X, Y]) GetByIndex(index int, defaults ...string) string
- func (a *KVxData[X, Y]) GetItem(k string, defaults ...func() *KVx[X, Y]) *KVx[X, Y]
- func (a *KVxData[X, Y]) GetItemByIndex(index int, defaults ...func() *KVx[X, Y]) *KVx[X, Y]
- func (a *KVxData[X, Y]) Has(k string) bool
- func (a *KVxData[X, Y]) Index(k string) []int
- func (a *KVxData[X, Y]) Indexes() map[string][]int
- func (a *KVxData[X, Y]) Keys() []string
- func (a *KVxData[X, Y]) Reset() *KVxData[X, Y]
- func (a *KVxData[X, Y]) Set(k, v string, options ...KVxOption[X, Y]) *KVxData[X, Y]
- func (a *KVxData[X, Y]) SetItem(item *KVx[X, Y]) *KVxData[X, Y]
- func (a *KVxData[X, Y]) Size() int
- func (a *KVxData[X, Y]) Slice() []*KVx[X, Y]
- type KVxList
- type KVxOption
- func KVxOptFn[X any, Y any](fn func(context.Context) Y) KVxOption[X, Y]
- func KVxOptH[X any, Y any](h H) KVxOption[X, Y]
- func KVxOptHKV[X any, Y any](k string, v interface{}) KVxOption[X, Y]
- func KVxOptK[X any, Y any](k string) KVxOption[X, Y]
- func KVxOptV[X any, Y any](v string) KVxOption[X, Y]
- func KVxOptX[X any, Y any](x X) KVxOption[X, Y]
- type LangCode
- type Mapx
- func (m *Mapx) Add(name string, values []string) *Mapx
- func (m *Mapx) AsFlatSlice() []string
- func (m *Mapx) AsMap() map[string]interface{}
- func (m *Mapx) AsSlice() []interface{}
- func (m *Mapx) AsStore() Store
- func (m *Mapx) Clone() *Mapx
- func (m *Mapx) Get(names ...string) *Mapx
- func (m *Mapx) IsMap() bool
- func (m *Mapx) IsSlice() bool
- 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 MetaValidator
- type MethodGetter
- 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) AddPreSaveHook(_ func(Context) error)
- 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) MustID() string
- func (n *NopSession) Options(_ SessionOptions) Sessioner
- func (n *NopSession) RemoveID(sessionID string) error
- func (n *NopSession) Save() error
- func (n *NopSession) Set(name string, value interface{}) Sessioner
- func (n *NopSession) SetID(id string, notReload ...bool) error
- func (n *NopSession) SetPreSaveHook(_ ...func(Context) error)
- type NopTranslate
- type NopValidation
- type PanicError
- func (p *PanicError) AddTrace(trace *Trace, content ...string) *PanicError
- func (p *PanicError) Debug() bool
- func (p *PanicError) Error() string
- func (p *PanicError) ExtractFileSnippets(file string, curLineNum int, index int) error
- func (p *PanicError) ExtractSnippets(content string, file string, curLineNum int, index int) error
- func (p *PanicError) HTML() template.HTML
- func (p *PanicError) JSONString() string
- func (p *PanicError) Parse(stackSizes ...int) *PanicError
- 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) Error() string
- func (d *RawData) GetCode() pkgCode.Code
- func (d *RawData) GetData() interface{}
- func (d *RawData) GetInfo() interface{}
- func (d *RawData) GetURL() string
- func (d *RawData) GetZone() interface{}
- func (d *RawData) Gets() (pkgCode.Code, interface{}, interface{}, interface{})
- func (d *RawData) JSON(codes ...int) error
- func (d *RawData) JSONP(callback string, codes ...int) error
- func (d *RawData) Reset() Data
- func (d *RawData) Set(code int, args ...interface{}) Data
- func (d *RawData) SetByMap(s Store) 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) SetURL(url string, args ...int) Data
- func (d *RawData) SetZone(zone interface{}) Data
- func (d *RawData) String() string
- func (d *RawData) XML(codes ...int) error
- type RenderContext
- type RenderContextWithData
- type RenderData
- func (r *RenderData) CaptchaForm(args ...interface{}) template.HTML
- func (r *RenderData) Cookie() Cookier
- func (r *RenderData) Decr(key string, n interface{}, defaults ...interface{}) int64
- func (r *RenderData) Domain() string
- func (r *RenderData) DurationFormat(t interface{}, args ...string) *com.Durafmt
- func (r *RenderData) Ext() string
- func (r *RenderData) Fetch(tmpl string, data interface{}) template.HTML
- func (r *RenderData) Flash(keys ...string) interface{}
- func (r *RenderData) Form(key string, defaults ...string) string
- func (r *RenderData) FormValues(key string) []string
- func (r *RenderData) Formx(key string, defaults ...string) param.String
- func (r *RenderData) FormxValues(key string) param.StringSlice
- func (r *RenderData) FullRequestURI() string
- func (r *RenderData) Get(key string, defaults ...interface{}) interface{}
- func (r *RenderData) GetNextURL(varNames ...string) string
- func (r *RenderData) GetOtherURL(urlStr string, next string) string
- func (r *RenderData) HasAnyRequest() bool
- func (r *RenderData) Header() engine.Header
- func (r *RenderData) Incr(key string, n interface{}, defaults ...interface{}) int64
- func (r *RenderData) IsHidden(a IsHiddenContext) bool
- func (r *RenderData) IsValid(a IsValidContext) bool
- func (r *RenderData) Lang() LangCode
- func (r *RenderData) MakeURL(h interface{}, args ...interface{}) string
- func (r *RenderData) Now() *com.Time
- func (r *RenderData) Param(key string, defaults ...string) string
- func (r *RenderData) Paramx(key string, defaults ...string) param.String
- func (r *RenderData) Path() string
- func (r *RenderData) Port() int
- func (r *RenderData) Prefix() string
- func (r *RenderData) Queries() map[string][]string
- func (r *RenderData) Query(key string, defaults ...string) string
- func (r *RenderData) QueryValues(key string) []string
- func (r *RenderData) Queryx(key string, defaults ...string) param.String
- func (r *RenderData) QueryxValues(key string) param.StringSlice
- func (r *RenderData) Referer() string
- func (r *RenderData) Render(a RenderContext) template.HTML
- func (r *RenderData) RenderWithData(a RenderContextWithData, data interface{}) template.HTML
- func (r *RenderData) RequestURI() string
- func (r *RenderData) ReturnToCurrentURL(varNames ...string) string
- func (r *RenderData) RootPrefix() string
- func (r *RenderData) Scheme() string
- func (r *RenderData) Session() Sessioner
- func (r *RenderData) Set(key string, value interface{}) string
- func (r *RenderData) Site() string
- func (r *RenderData) SiteURI() string
- func (r *RenderData) T(format string, args ...interface{}) string
- func (r *RenderData) ThemeColor() string
- func (r *RenderData) TimeAgo(v interface{}, options ...string) string
- func (r *RenderData) TsHumanize(startTime interface{}, endTime ...interface{}) string
- func (r *RenderData) URI() string
- func (r *RenderData) URL() engine.URL
- func (r *RenderData) UnixTime() int64
- func (r *RenderData) WithNextURL(urlStr string, varNames ...string) string
- type Renderer
- type RendererRegister
- type RequestValidator
- type Rewriter
- type Route
- func (r *Route) Bool(name string, defaults ...interface{}) bool
- func (r *Route) Float32(name string, defaults ...interface{}) float32
- func (r *Route) Float64(name string, defaults ...interface{}) float64
- func (r *Route) Get(name string, defaults ...interface{}) interface{}
- func (r *Route) GetMeta() H
- func (r *Route) GetName() string
- func (r *Route) GetStore(names ...string) H
- func (r *Route) Int(name string, defaults ...interface{}) int
- func (r *Route) Int32(name string, defaults ...interface{}) int32
- func (r *Route) Int64(name string, defaults ...interface{}) int64
- func (r *Route) IsZero() bool
- func (r *Route) MakeURI(e *Echo, params ...interface{}) (uri string)
- func (r *Route) SetMeta(meta H) IRouter
- func (r *Route) SetMetaKV(key string, value interface{}) IRouter
- func (r *Route) SetName(name string) IRouter
- func (r *Route) String(name string, defaults ...interface{}) string
- func (r *Route) Uint(name string, defaults ...interface{}) uint
- func (r *Route) Uint32(name string, defaults ...interface{}) uint32
- func (r *Route) Uint64(name string, defaults ...interface{}) uint64
- type RouteRegister
- type Router
- type Routes
- type SessionOptions
- type Sessioner
- type Skipper
- type Snippet
- type SnippetGroup
- type Store
- type Template
- type ToConversion
- type Trace
- type Transaction
- type Translator
- type TypeHost
- type URLBuilder
- type UnwrapTransaction
- type ValidateResult
- type Validation
- type Validator
- type ValidatorResult
- func (v *ValidatorResult) AsError() 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
- func (v *ValidatorResult) Unwrap() error
- type ValueDecodersGetter
- type ValueEncodersGetter
- type ValueStringersGetter
- type XContext
- func (c *XContext) Accept() *Accepts
- func (c *XContext) AddHostParam(name string, value string)
- func (c *XContext) AddPreResponseHook(hook func() error) Context
- func (c *XContext) Atop(v string) param.String
- func (c *XContext) Attachment(r io.Reader, name string, modtime time.Time, inline ...bool) error
- func (c *XContext) Begin() error
- func (c *XContext) Bind(i interface{}, filter ...FormDataFilter) error
- func (c *XContext) BindAndValidate(i interface{}, filter ...FormDataFilter) error
- func (c *XContext) BindAndValidateWithDecoder(i interface{}, valueDecoders BinderValueCustomDecoders, ...) error
- func (c *XContext) BindWithDecoder(i interface{}, valueDecoders BinderValueCustomDecoders, ...) error
- func (c *XContext) Blob(b []byte, codes ...int) (err error)
- func (c *XContext) CacheableAttachment(r io.Reader, name string, modtime time.Time, maxAge time.Duration, ...) error
- func (c *XContext) CacheableFile(file string, maxAge time.Duration, fs ...http.FileSystem) (err error)
- func (c *XContext) Code() int
- func (c *XContext) Commit() error
- func (c *XContext) Cookie() Cookier
- func (c *XContext) CookieOptions() *CookieOptions
- func (c *XContext) Data() Data
- func (c *XContext) Deadline() (deadline time.Time, ok bool)
- func (c *XContext) Decr(key string, n interface{}, defaults ...interface{}) int64
- func (c *XContext) DefaultExtension() string
- func (c *XContext) Delete(keys ...string)
- func (c *XContext) Dispatch(route string) Handler
- func (c *XContext) Domain() string
- func (c *XContext) Done() <-chan struct{}
- func (c *XContext) Echo() *Echo
- func (c *XContext) End(succeed bool) error
- func (c *XContext) Err() error
- func (c *XContext) Error(err error)
- func (c *XContext) Fetch(name string, data interface{}) (b []byte, err error)
- func (c *XContext) File(file string, fs ...http.FileSystem) error
- func (c *XContext) FireHostFound() (bool, error)
- func (c *XContext) Flash(names ...string) (r interface{})
- func (c *XContext) Form(name string, defaults ...string) (value string)
- func (c *XContext) FormValues(name string) []string
- func (c *XContext) Format() string
- func (c *XContext) Forms() map[string][]string
- func (c *XContext) Formx(name string, defaults ...string) param.String
- func (c *XContext) FormxValues(name string) param.StringSlice
- func (c *XContext) FullRequestURI() string
- func (c *XContext) Funcs() map[string]interface{}
- func (c *XContext) Get(key string, defaults ...interface{}) interface{}
- func (c *XContext) GetCookie(key string) string
- func (c *XContext) GetFunc(key string) interface{}
- func (c *XContext) HTML(html string, codes ...int) error
- func (c *XContext) Handle(ctx Context) error
- func (c *XContext) Handler() Handler
- func (c *XContext) HasAnyRequest() bool
- func (c *XContext) Header(name string) string
- func (c *XContext) Host() string
- func (c *XContext) HostP(i int, defaults ...string) (value string)
- func (c *XContext) HostParam(name string, defaults ...string) (value string)
- func (c *XContext) HostParamNames() []string
- func (c *XContext) HostParamValues() []string
- func (c *XContext) Incr(key string, n interface{}, defaults ...interface{}) int64
- func (c *XContext) Internal() *param.SafeMap
- func (c *XContext) IsAjax() bool
- func (c *XContext) IsDel() bool
- func (c *XContext) IsGet() bool
- func (c *XContext) IsHead() bool
- func (c *XContext) IsMethod(method string) bool
- func (c *XContext) IsOptions() bool
- func (c *XContext) IsPatch() bool
- func (c *XContext) IsPjax() bool
- func (c *XContext) IsPost() bool
- func (c *XContext) IsPut() bool
- func (c *XContext) IsSecure() bool
- func (c *XContext) IsUpload() bool
- func (c *XContext) IsValidCache(modifiedAt time.Time) bool
- func (c *XContext) IsWebsocket() bool
- func (c *XContext) JSON(i interface{}, codes ...int) (err error)
- func (c *XContext) JSONBlob(b []byte, codes ...int) (err error)
- func (c *XContext) JSONP(callback string, i interface{}, codes ...int) (err error)
- func (c *XContext) Logger() logger.Logger
- func (c *XContext) MapData(i interface{}, data map[string][]string, names ...string) error
- func (c *XContext) MapForm(i interface{}, names ...string) error
- func (c *XContext) Method() string
- func (c *XContext) MustBind(i interface{}, filter ...FormDataFilter) error
- func (c *XContext) MustBindAndValidate(i interface{}, filter ...FormDataFilter) error
- func (c *XContext) MustBindAndValidateWithDecoder(i interface{}, valueDecoders BinderValueCustomDecoders, ...) error
- func (c *XContext) MustBindWithDecoder(i interface{}, valueDecoders BinderValueCustomDecoders, ...) error
- func (c *XContext) NewCookie(key string, value string) *http.Cookie
- func (c *XContext) NewError(code pkgCode.Code, msg string, args ...interface{}) *Error
- func (c *XContext) NewErrorWith(err error, code pkgCode.Code, args ...interface{}) *Error
- func (c *XContext) NoContent(codes ...int) error
- func (c *XContext) NotModified() error
- func (c *XContext) Object() *XContext
- func (c *XContext) OnHostFound(onHostFound func(Context) (bool, error)) Context
- func (c *XContext) P(i int, defaults ...string) (value string)
- func (c *XContext) Param(name string, defaults ...string) (value string)
- func (c *XContext) ParamNames() []string
- func (c *XContext) ParamValues() []string
- func (c *XContext) Paramx(name string, defaults ...string) param.String
- func (c *XContext) Path() string
- func (c *XContext) PjaxContainer() string
- func (c *XContext) Port() int
- func (c *XContext) PrintFuncs()
- func (c *XContext) Protocol() string
- func (c *XContext) Proxy() []string
- func (c *XContext) Px(n int, defaults ...string) param.String
- func (c *XContext) Queries() map[string][]string
- func (c *XContext) Query(name string, defaults ...string) (value string)
- func (c *XContext) QueryValues(name string) []string
- func (c *XContext) Queryx(name string, defaults ...string) param.String
- func (c *XContext) QueryxValues(name string) param.StringSlice
- func (c *XContext) RealIP() string
- func (c *XContext) Redirect(url string, codes ...int) error
- func (c *XContext) Referer() string
- func (c *XContext) Render(name string, data interface{}, codes ...int) error
- func (c *XContext) RenderBy(name string, content func(string) ([]byte, error), data interface{}, ...) (b []byte, err error)
- func (c *XContext) RenderDataWrapper() DataWrapper
- func (c *XContext) Renderer() Renderer
- func (c *XContext) Request() engine.Request
- func (c *XContext) RequestURI() string
- func (c *XContext) Reset(req engine.Request, res engine.Response)
- func (c *XContext) ResetFuncs(funcs map[string]interface{})
- func (c *XContext) ResolveContentType() string
- func (c *XContext) ResolveFormat() string
- func (c *XContext) Response() engine.Response
- func (c *XContext) Rollback() error
- func (c *XContext) Route() *Route
- func (c *XContext) SSEvent(event string, data chan interface{}) error
- func (c *XContext) SaveUploadedFile(fieldName string, saveAbsPath string, ...) (*multipart.FileHeader, error)
- func (c *XContext) SaveUploadedFileToWriter(fieldName string, writer io.Writer) (*multipart.FileHeader, error)
- func (c *XContext) SaveUploadedFiles(fieldName string, savePath func(*multipart.FileHeader) (string, error)) error
- func (c *XContext) SaveUploadedFilesToWriter(fieldName string, writer func(*multipart.FileHeader) (io.Writer, error)) error
- func (c *XContext) Scheme() string
- func (c *XContext) ServeCallbackContent(callback func(Context) (io.Reader, error), name string, modtime time.Time, ...) error
- func (c *XContext) ServeContent(content io.Reader, name string, modtime time.Time, ...) error
- func (c *XContext) Session() Sessioner
- func (c *XContext) SessionOptions() *SessionOptions
- func (c *XContext) Set(key string, val interface{})
- func (c *XContext) SetAuto(on bool) Context
- func (c *XContext) SetCacheHeader(modifiedAt time.Time, maxAge ...time.Duration)
- func (c *XContext) SetCode(code int)
- func (c *XContext) SetCookie(key string, val string, args ...interface{})
- func (c *XContext) SetCookieOptions(opts *CookieOptions)
- func (c *XContext) SetData(data Data)
- func (c *XContext) SetDefaultExtension(ext string)
- func (c *XContext) SetEmitterer(emitterer events.Emitterer)
- func (c *XContext) SetFormat(format string)
- func (c *XContext) SetFunc(key string, val interface{})
- func (c *XContext) SetHostParamNames(names ...string)
- func (c *XContext) SetHostParamValues(values ...string)
- func (c *XContext) SetParamNames(names ...string)
- func (c *XContext) SetParamValues(values ...string)
- func (c *XContext) SetPreResponseHook(hook ...func() error) Context
- func (c *XContext) SetRenderDataWrapper(dataWrapper DataWrapper)
- func (c *XContext) SetRenderer(r Renderer)
- func (c *XContext) SetSessionOptions(opts *SessionOptions)
- func (c *XContext) SetSessioner(s Sessioner)
- func (c *XContext) SetTransaction(t Transaction)
- func (c *XContext) SetTranslator(t Translator)
- func (c *XContext) SetValidator(v Validator)
- func (c *XContext) SetValue(key string, value interface{})
- func (c *XContext) Site() string
- func (c *XContext) StdContext() context.Context
- func (c *XContext) Stored() Store
- func (c *XContext) Stream(step func(w io.Writer) (bool, error)) error
- func (c *XContext) String(s string, codes ...int) error
- func (c *XContext) ToParamString(v string) param.String
- func (c *XContext) ToStringSlice(v []string) param.StringSlice
- func (c *XContext) Transaction() Transaction
- func (c *XContext) Validate(item interface{}, args ...interface{}) error
- func (c *XContext) Validator() Validator
- func (c *XContext) Value(key interface{}) interface{}
- func (c *XContext) WithContext(ctx context.Context) *http.Request
- func (c *XContext) WithFormatExtension(on bool)
- func (c *XContext) XML(i interface{}, codes ...int) (err error)
- func (c *XContext) XMLBlob(b []byte, codes ...int) (err error)
- type XMLModifer
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 MIMETextJavaScript = "text/javascript" MIMETextJavaScriptCharsetUTF8 = MIMETextJavaScript + "; " + CharsetUTF8 MIMETextCSS = "text/css" MIMETextCSSCharsetUTF8 = MIMETextCSS + "; " + 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" HeaderXForwardedPort = "X-Forwarded-Port" 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" HeaderExpires = "Expires" HeaderCacheControl = "Cache-Control" CacheControlPrefix = "public, max-age=" HeaderConnection = "Connection" HeaderTransferEncoding = "Transfer-Encoding" // 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) // Content Type ContentTypeHTML = "html" ContentTypeJSON = "json" ContentTypeJSONP = "jsonp" ContentTypeXML = "xml" ContentTypeText = "text" // HTTP Scheme SchemeHTTP = "http" SchemeHTTPS = "https" )
const ( SnippetLineNumbers = 13 StackSize = 4 << 10 // 4 KB )
Variables ¶
var ( ErrBreak = errors.New("[BREAK]") ErrContinue = errors.New("[CONTINUE]") ErrExit = errors.New("[EXIT]") ErrReturn = errors.New("[RETURN]") ErrSliceIndexTooLarge = errors.New("the slice index value of the form field is too large") )
var ( //DefaultNopFilter 默认过滤器(map->struct) DefaultNopFilter FormDataFilter = func(k string, v []string) (string, []string) { return k, v } //DateToTimestamp 日期时间转时间戳 DateToTimestamp = func(layouts ...string) FormDataFilter { layout := `2006-01-02` if len(layouts) > 0 && len(layouts[0]) > 0 { layout = layouts[0] } return func(k string, v []string) (string, []string) { if len(v) > 0 && len(v[0]) > 0 { t, e := time.ParseInLocation(layout, v[0], time.Local) if e != nil { log.Error(e) return k, []string{`0`} } return k, []string{fmt.Sprint(t.Unix())} } return k, []string{`0`} } } //TimestampToDate 时间戳转日期时间 TimestampToDate = func(layouts ...string) FormDataFilter { layout := `2006-01-02 15:04:05` if len(layouts) > 0 && len(layouts[0]) > 0 { layout = layouts[0] } return func(k string, v []string) (string, []string) { if len(v) > 0 && len(v[0]) > 0 { tsi := strings.SplitN(v[0], `.`, 2) var sec, nsec int64 switch len(tsi) { case 2: nsec = param.AsInt64(tsi[1]) fallthrough case 1: sec = param.AsInt64(tsi[0]) } t := time.Unix(sec, nsec) if t.IsZero() { return k, []string{``} } return k, []string{t.Format(layout)} } return k, v } } //JoinValues 组合数组为字符串 JoinValues = func(seperators ...string) FormDataFilter { sep := `,` if len(seperators) > 0 { sep = seperators[0] } return func(k string, v []string) (string, []string) { return k, []string{strings.Join(v, sep)} } } //SplitValues 拆分字符串为数组 SplitValues = func(seperators ...string) FormDataFilter { sep := `,` if len(seperators) > 0 { sep = seperators[0] } return func(k string, v []string) (string, []string) { if len(v) > 0 && len(v[0]) > 0 { v = strings.Split(v[0], sep) } return k, v } } )
var ( TimestampStringer = param.TimestampStringer DateTimeStringer = param.DateTimeStringer WhitespaceStringer = param.WhitespaceStringer Ignored = param.Ignored )
var ( DefaultNopSession Sessioner = &NopSession{} DefaultDebugSession Sessioner = &DebugSession{} DefaultSession = DefaultNopSession DefaultSessionOptions = NewSessionOptions(`cookie`, `SID`) )
var ( ErrUnsupportedMediaType error = NewHTTPError(http.StatusUnsupportedMediaType) ErrBadRequest error = NewHTTPError(http.StatusBadRequest) ErrPaymentRequired error = NewHTTPError(http.StatusPaymentRequired) ErrNotAcceptable error = NewHTTPError(http.StatusNotAcceptable) ErrProxyAuthRequired error = NewHTTPError(http.StatusProxyAuthRequired) ErrRequestTimeout error = NewHTTPError(http.StatusRequestTimeout) ErrConflict error = NewHTTPError(http.StatusConflict) ErrGone error = NewHTTPError(http.StatusGone) ErrLengthRequired error = NewHTTPError(http.StatusLengthRequired) ErrPreconditionFailed error = NewHTTPError(http.StatusPreconditionFailed) ErrRequestEntityTooLarge error = NewHTTPError(http.StatusRequestEntityTooLarge) ErrRequestURITooLong error = NewHTTPError(http.StatusRequestURITooLong) ErrRequestedRangeNotSatisfiable error = NewHTTPError(http.StatusRequestedRangeNotSatisfiable) ErrExpectationFailed error = NewHTTPError(http.StatusExpectationFailed) ErrUnprocessableEntity error = NewHTTPError(http.StatusUnprocessableEntity) ErrLocked error = NewHTTPError(http.StatusLocked) ErrFailedDependency error = NewHTTPError(http.StatusFailedDependency) ErrTooEarly error = NewHTTPError(http.StatusTooEarly) ErrUpgradeRequired error = NewHTTPError(http.StatusUpgradeRequired) ErrPreconditionRequired error = NewHTTPError(http.StatusPreconditionRequired) ErrTooManyRequests error = NewHTTPError(http.StatusTooManyRequests) ErrRequestHeaderFieldsTooLarge error = NewHTTPError(http.StatusRequestHeaderFieldsTooLarge) ErrNotImplemented error = NewHTTPError(http.StatusNotImplemented) 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") ErrNotFoundFileInput = errors.New("the specified name file input was not found") NotFoundHandler = HandlerFunc(func(c Context) error { return ErrNotFound }) ErrorHandler = func(err error) Handler { return HandlerFunc(func(c Context) error { return err }) } MethodNotAllowedHandler = HandlerFunc(func(c Context) error { return ErrMethodNotAllowed }) StringerMapStart = param.StringerMapStart StoreStart = param.StoreStart HStart = param.StoreStart )
var ( DefaultAcceptFormats = map[string]string{ MIMEApplicationJSON: ContentTypeJSON, `text/javascript`: ContentTypeJSON, MIMEApplicationJavaScript: ContentTypeJSON, MIMEApplicationXML: ContentTypeXML, `text/xml`: ContentTypeXML, MIMETextPlain: ContentTypeText, `*/*`: ContentTypeHTML, `application/xhtml`: ContentTypeHTML, MIMETextHTML: ContentTypeHTML, `*`: ContentTypeHTML, } DefaultFormatRenderers = map[string]FormatRender{ ContentTypeJSON: func(c Context, data interface{}) error { return c.JSON(c.Data()) }, ContentTypeJSONP: func(c Context, data interface{}) error { return c.JSONP(c.Query(c.Echo().JSONPVarName), c.Data()) }, ContentTypeXML: func(c Context, data interface{}) error { return c.XML(c.Data()) }, ContentTypeText: func(c Context, data interface{}) error { return c.String(fmt.Sprint(data)) }, } DefaultBinderDecoders = map[string]func(interface{}, Context, BinderValueCustomDecoders, ...FormDataFilter) error{ MIMEApplicationJSON: func(i interface{}, ctx Context, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error { body := ctx.Request().Body() if body == nil { return NewHTTPError(http.StatusBadRequest, "Request body can't be nil") } defer body.Close() err := json.NewDecoder(body).Decode(i) if err != nil { switch ev := err.(type) { case *stdJSON.UnmarshalTypeError: return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unmarshal type error: expected=%v, got=%v, field=%v, offset=%v", ev.Type, ev.Value, ev.Field, ev.Offset)).SetRaw(err) case *stdJSON.SyntaxError: return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: offset=%v, error=%v", ev.Offset, ev.Error())).SetRaw(err) } return NewHTTPError(http.StatusBadRequest, err.Error()).SetRaw(err) } return err }, MIMEApplicationXML: func(i interface{}, ctx Context, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error { body := ctx.Request().Body() if body == nil { return NewHTTPError(http.StatusBadRequest, "Request body can't be nil") } defer body.Close() err := xml.NewDecoder(body).Decode(i) if err != nil { switch ev := err.(type) { case *xml.UnsupportedTypeError: return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unsupported type error: type=%v, error=%v", ev.Type, ev.Error())).SetRaw(err) case *xml.SyntaxError: return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Syntax error: line=%v, error=%v", ev.Line, ev.Error())).SetRaw(err) } return NewHTTPError(http.StatusBadRequest, err.Error()).SetRaw(err) } return err }, MIMEApplicationForm: func(i interface{}, ctx Context, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error { return FormToStructWithDecoder(ctx.Echo(), i, ctx.Request().PostForm().All(), ``, valueDecoders, filter...) }, MIMEMultipartForm: func(i interface{}, ctx Context, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error { _, err := ctx.Request().MultipartForm() if err != nil && !errors.Is(err, http.ErrMissingBoundary) { return err } return FormToStructWithDecoder(ctx.Echo(), i, ctx.Request().Form().All(), ``, valueDecoders, filter...) }, `*`: func(i interface{}, ctx Context, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error { return FormToStructWithDecoder(ctx.Echo(), i, ctx.Request().Form().All(), ``, valueDecoders, filter...) }, } // DefaultHTMLFilter html filter (`form_filter:"html"`) DefaultHTMLFilter = func(v string) (r string) { return v } DefaultBinderValueEncoders = map[string]BinderValueEncoder{ `joinKVRows`: binderValueEncoderJoinKVRows, `join`: binderValueEncoderJoin, `unix2time`: binderValueEncoderUnix2time, } DefaultBinderValueDecoders = map[string]BinderValueDecoder{ `splitKVRows`: binderValueDecoderSplitKVRows, `split`: binderValueDecoderSplit, `time2unix`: binderValueDecoderTime2unix, } )
var AsStore = param.AsStore
var ( DefaultCookieOptions = &CookieOptions{ Path: `/`, Cryptor: NewCookieCryptor(codec.Default, com.RandomString(16)), } )
var DefaultNextURLVarName = `next`
Functions ¶
func AddListener ¶ added in v1.6.0
func AsStdContext ¶ added in v1.6.0
func CaptureTokens ¶ added in v1.3.5
func CaptureTokensByValues ¶ added in v1.6.0
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 CookieExpires ¶ added in v1.6.0
CookieExpires 设置过期时间 所有浏览器都支持 如果仅仅设置Expires,因为过期时间是固定的,所以不会导致保存Cookie时被续期
func CookieMaxAge ¶ added in v1.6.0
CookieMaxAge 设置有效时长(秒) IE6/7/8不支持 如果同时设置了MaxAge和Expires,则优先使用MaxAge 设置MaxAge则代表每次保存Cookie都会续期,因为MaxAge是基于保存时间来设置的
func CookieSameSite ¶ added in v1.6.0
CookieSameSite 设置SameSite
func CopyCookieOptions ¶ added in v1.6.0
CopyCookieOptions copy cookie options
func DefaultRenderDataWrapper ¶ added in v1.6.0
func DefaultRenderDataWrapper(ctx Context, data interface{}) interface{}
func DefaultSkipper ¶
DefaultSkipper returns false which processes the middleware.
func DetectError ¶ added in v1.6.0
func EventNames ¶ added in v1.6.0
func EventNames() []string
func FireByName ¶ added in v1.6.0
func FireByName(name string, options ...events.EventOption) error
func FlatStructToForm ¶ added in v1.6.0
func FlatStructToForm(ctx Context, m interface{}, fieldNameFormatter FieldNameFormatter, formatters ...param.StringerMap)
FlatStructToForm 映射struct到form
func FormToMapWithDecoder ¶ added in v1.6.0
func FormToMapWithDecoder(e *Echo, m interface{}, data map[string][]string, topName string, valueDecoders BinderValueCustomDecoders, filters ...FormDataFilter) error
func FormToStruct ¶ added in v1.6.0
func FormToStructWithDecoder ¶ added in v1.6.0
func FormToStructWithDecoder(e *Echo, m interface{}, data map[string][]string, topName string, valueDecoders BinderValueCustomDecoders, filters ...FormDataFilter) error
func GetNextURL ¶ added in v1.6.0
func GetOrSet ¶ added in v1.4.2
func GetOrSet(key, value interface{}) (actual interface{}, loaded bool)
func GetOtherURL ¶ added in v1.6.0
func GetValidated ¶ added in v1.6.0
func GetValidated(c Context, defaults ...interface{}) interface{}
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 InSliceFold ¶ added in v1.6.0
func InterfacesToStrings ¶ added in v1.6.0
func InterfacesToStrings(args []interface{}) []string
func MustGetValidated ¶ added in v1.6.0
func MustValidated ¶ added in v1.6.0
func NamedStructMap ¶
func NamedStructMap(e *Echo, m interface{}, data map[string][]string, topName string, filters ...FormDataFilter) error
NamedStructMap 自动将map值映射到结构体
func NamedStructMapWithDecoder ¶ added in v1.6.0
func NamedStructMapWithDecoder(e *Echo, m interface{}, data map[string][]string, topName string, valueDecoders BinderValueCustomDecoders, filters ...FormDataFilter) error
func NewCookie ¶
func NewCookie(key, value string, opt *CookieOptions) *http.Cookie
NewCookie 新建cookie对象
func NewEvent ¶ added in v1.6.0
func NewEvent(data interface{}, options ...events.EventOption) events.Event
func OnCallback ¶ added in v1.6.0
func ParseURIRegExp ¶ added in v1.6.0
func RemoveListener ¶ added in v1.6.0
func ReturnToCurrentURL ¶ added in v1.6.0
func SafeGetFieldByName ¶ added in v1.6.0
func SearchEngineNoindex ¶ added in v1.10.10
func SearchEngineNoindex(c Context)
func SetAttachmentHeader ¶ added in v1.6.0
func SetFormValue ¶ added in v1.5.0
func SetFormValues ¶ added in v1.6.0
func SetReflectValue ¶ added in v1.6.0
func SetWorkDir ¶ added in v1.4.3
func SetWorkDir(dir string)
func Split ¶ added in v1.4.3
func Split(key interface{}, sep string, limit ...int) param.StringSlice
func StructToForm ¶ added in v1.1.0
func StructToForm(ctx Context, m interface{}, topName string, fieldNameFormatter FieldNameFormatter, formatters ...param.StringerMap)
func ToStdContext ¶ added in v1.6.0
func TranslateStringer ¶ added in v1.6.0
func TranslateStringer(t Translator, args ...interface{}) param.Stringer
func ValidateStruct ¶ added in v1.6.0
Types ¶
type AcceptQuality ¶ added in v1.6.0
type Accepts ¶ added in v1.3.9
type Accepts struct { Raw string Accepts []*AcceptQuality }
func NewAccepts ¶ added in v1.3.9
type AfterValidate ¶ added in v1.6.0
type AsMiddleware ¶ added in v1.5.0
func (AsMiddleware) Handle ¶ added in v1.5.0
func (m AsMiddleware) Handle(h Handler) Handler
type BaseRequestValidator ¶ added in v1.6.0
type BaseRequestValidator struct {
// contains filtered or unexported fields
}
func NewBaseRequestValidator ¶ added in v1.6.0
func NewBaseRequestValidator(data interface{}, method ...string) *BaseRequestValidator
func (*BaseRequestValidator) Filters ¶ added in v1.6.0
func (b *BaseRequestValidator) Filters(c Context) []FormDataFilter
func (*BaseRequestValidator) Methods ¶ added in v1.6.0
func (b *BaseRequestValidator) Methods() []string
func (*BaseRequestValidator) SetStruct ¶ added in v1.6.0
func (b *BaseRequestValidator) SetStruct(data interface{}) *BaseRequestValidator
func (*BaseRequestValidator) ValueDecoders ¶ added in v1.6.0
func (b *BaseRequestValidator) ValueDecoders(c Context) BinderValueCustomDecoders
type BaseTransaction ¶ added in v1.3.9
type BaseTransaction struct { Transaction // contains filtered or unexported fields }
func NewTransaction ¶ added in v1.3.9
func NewTransaction(trans Transaction) *BaseTransaction
func (*BaseTransaction) Begin ¶ added in v1.3.9
func (b *BaseTransaction) Begin(ctx context.Context) error
func (*BaseTransaction) Commit ¶ added in v1.3.9
func (b *BaseTransaction) Commit(ctx context.Context) error
func (*BaseTransaction) End ¶ added in v1.3.9
func (b *BaseTransaction) End(ctx context.Context, succeed bool) error
func (*BaseTransaction) Rollback ¶ added in v1.3.9
func (b *BaseTransaction) Rollback(ctx context.Context) error
func (*BaseTransaction) Unwrap ¶ added in v1.6.0
func (b *BaseTransaction) Unwrap() Transaction
type BeforeBind ¶ added in v1.6.0
type BeforeValidate ¶ added in v1.6.0
type Binder ¶
type Binder interface { Bind(interface{}, Context, ...FormDataFilter) error BindAndValidate(interface{}, Context, ...FormDataFilter) error MustBind(interface{}, Context, ...FormDataFilter) error MustBindAndValidate(interface{}, Context, ...FormDataFilter) error BindWithDecoder(interface{}, Context, BinderValueCustomDecoders, ...FormDataFilter) error BindAndValidateWithDecoder(interface{}, Context, BinderValueCustomDecoders, ...FormDataFilter) error MustBindWithDecoder(interface{}, Context, BinderValueCustomDecoders, ...FormDataFilter) error MustBindAndValidateWithDecoder(interface{}, Context, BinderValueCustomDecoders, ...FormDataFilter) error }
Binder is the interface that wraps the Bind method.
type BinderFormTopNamer ¶ added in v1.6.0
type BinderFormTopNamer interface {
BinderFormTopName() string
}
type BinderKeyNormalizer ¶ added in v1.6.0
type BinderValueCustomDecoder ¶ added in v1.6.0
type BinderValueCustomDecoders ¶ added in v1.6.0
type BinderValueCustomDecoders map[string]BinderValueCustomDecoder // 这里的 key 为结构体字段或map的key层级路径
type BinderValueCustomEncoder ¶ added in v1.6.0
type BinderValueCustomEncoder func(interface{}) []string
func FormStringer ¶ added in v1.6.0
func FormStringer(s param.Stringer) BinderValueCustomEncoder
type BinderValueCustomEncoders ¶ added in v1.6.0
type BinderValueCustomEncoders map[string]BinderValueCustomEncoder // 这里的 key 为表单字段层级路径
type BinderValueDecoder ¶ added in v1.6.0
type BinderValueEncoder ¶ added in v1.6.0
type Context ¶
type Context interface { context.Context events.Emitterer SetEmitterer(events.Emitterer) Handler() Handler //Transaction SetTransaction(t Transaction) Transaction() Transaction Begin() error Rollback() error Commit() error End(succeed bool) error //Standard Context StdContext() context.Context WithContext(ctx context.Context) *http.Request SetValue(key string, value interface{}) SetValidator(Validator) Validator() Validator Validate(item interface{}, args ...interface{}) error 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) Dispatch(route string) Handler Path() string P(int, ...string) string Param(string, ...string) string // ParamNames returns path parameter names. ParamNames() []string ParamValues() []string SetParamNames(names ...string) SetParamValues(values ...string) // Host HostParamNames() []string HostParamValues() []string HostParam(string, ...string) string HostP(int, ...string) string SetHostParamNames(names ...string) SetHostParamValues(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{} Incr(key string, n interface{}, defaults ...interface{}) int64 Decr(key string, n interface{}, defaults ...interface{}) int64 Delete(...string) Stored() Store Internal() *param.SafeMap Bind(interface{}, ...FormDataFilter) error BindAndValidate(interface{}, ...FormDataFilter) error MustBind(interface{}, ...FormDataFilter) error MustBindAndValidate(interface{}, ...FormDataFilter) error BindWithDecoder(interface{}, BinderValueCustomDecoders, ...FormDataFilter) error BindAndValidateWithDecoder(interface{}, BinderValueCustomDecoders, ...FormDataFilter) error MustBindWithDecoder(interface{}, BinderValueCustomDecoders, ...FormDataFilter) error MustBindAndValidateWithDecoder(interface{}, BinderValueCustomDecoders, ...FormDataFilter) error Render(string, interface{}, ...int) error RenderBy(string, func(string) ([]byte, error), interface{}, ...int) ([]byte, 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, error)) error SSEvent(string, chan interface{}) error File(string, ...http.FileSystem) error CacheableFile(string, time.Duration, ...http.FileSystem) error Attachment(io.Reader, string, time.Time, ...bool) error CacheableAttachment(io.Reader, string, time.Time, time.Duration, ...bool) error NotModified() error NoContent(...int) error Redirect(string, ...int) error Error(err error) NewError(code pkgCode.Code, msg string, args ...interface{}) *Error NewErrorWith(err error, code pkgCode.Code, args ...interface{}) *Error SetCode(int) Code() int SetData(Data) Data() Data IsValidCache(modifiedAt time.Time) bool SetCacheHeader(modifiedAt time.Time, maxAge ...time.Duration) // 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.Reader, string, time.Time, ...time.Duration) error ServeCallbackContent(func(Context) (io.Reader, error), string, time.Time, ...time.Duration) 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) SetRenderDataWrapper(DataWrapper) Renderer() Renderer RenderDataWrapper() DataWrapper SetCookieOptions(*CookieOptions) CookieOptions() *CookieOptions NewCookie(string, string) *http.Cookie Cookie() Cookier GetCookie(string) string // SetCookie set cookie // @param: key, value, maxAge(seconds), path(/), domain, secure(false), httpOnly(false), sameSite(lax/strict/default) 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) IsMethod(method string) bool IsPost() bool IsGet() bool IsPut() bool IsDel() bool IsHead() bool IsPatch() bool IsOptions() bool IsSecure() bool IsWebsocket() bool IsUpload() bool ResolveContentType() string WithFormatExtension(bool) SetDefaultExtension(string) DefaultExtension() string ResolveFormat() string Accept() *Accepts Protocol() string Site() string FullRequestURI() string RequestURI() 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 ...func(*multipart.FileHeader) (string, error)) (*multipart.FileHeader, error) SaveUploadedFileToWriter(string, io.Writer) (*multipart.FileHeader, error) //Multiple file upload SaveUploadedFiles(fieldName string, savePath func(*multipart.FileHeader) (string, error)) error SaveUploadedFilesToWriter(fieldName string, writer func(*multipart.FileHeader) (io.Writer, error)) error AddPreResponseHook(func() error) Context SetPreResponseHook(...func() error) Context OnHostFound(func(Context) (bool, error)) Context FireHostFound() (bool, error) }
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 ContextReseter ¶ added in v1.8.2
type CookieCryptor ¶ added in v1.12.0
type CookieCryptor interface { EncryptString(input string) (string, error) DecryptString(input string) (string, error) }
func NewCookieCryptor ¶ added in v1.12.0
func NewCookieCryptor(codec Codec, secret string) CookieCryptor
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 // Expires Expires time.Time Path string Domain string Secure bool HttpOnly bool SameSite string // strict / lax Cryptor CookieCryptor }
CookieOptions cookie options
func (*CookieOptions) Clone ¶ added in v1.3.0
func (c *CookieOptions) Clone() *CookieOptions
func (*CookieOptions) DecryptString ¶ added in v1.12.0
func (c *CookieOptions) DecryptString(input string) (string, error)
func (*CookieOptions) EncryptString ¶ added in v1.12.0
func (c *CookieOptions) EncryptString(input string) (string, error)
func (*CookieOptions) SetMaxAge ¶ added in v1.6.0
func (c *CookieOptions) SetMaxAge(maxAge int) *CookieOptions
type Cookier ¶
type Cookier interface { Get(key string) string DecryptGet(key string) string Add(cookies ...*http.Cookie) Cookier Set(key string, val string, args ...interface{}) Cookier EncryptSet(key string, val string, args ...interface{}) Cookier Send() }
Cookier interface
type Data ¶
type Data interface { SetTmplFuncs() SetContext(ctx Context) Data String() string Set(code int, args ...interface{}) Data Reset() Data SetByMap(Store) Data SetError(err error, args ...int) Data SetCode(code int) Data SetURL(url string, args ...int) Data SetInfo(info interface{}, args ...int) Data SetZone(zone interface{}) Data SetData(data interface{}, args ...int) Data Gets() (code pkgCode.Code, info interface{}, zone interface{}, data interface{}) GetCode() pkgCode.Code GetInfo() interface{} GetZone() interface{} GetData() interface{} GetURL() string JSONP(callback string, codes ...int) error JSON(codes ...int) error XML(codes ...int) error }
Data 响应数据
type DataWrapper ¶ added in v1.6.0
type DataWrapper func(Context, interface{}) interface{}
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) AddPreSaveHook ¶ added in v1.6.0
func (n *DebugSession) AddPreSaveHook(_ func(Context) error)
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) MustID ¶ added in v1.6.0
func (n *DebugSession) MustID() string
func (*DebugSession) Options ¶ added in v1.3.5
func (n *DebugSession) Options(options SessionOptions) Sessioner
func (*DebugSession) RemoveID ¶ added in v1.6.0
func (n *DebugSession) RemoveID(sessionID string) error
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, notReload ...bool) error
func (*DebugSession) SetPreSaveHook ¶ added in v1.6.0
func (n *DebugSession) SetPreSaveHook(_ ...func(Context) error)
type DebugTransaction ¶ added in v1.5.0
type DebugTransaction struct { }
func (*DebugTransaction) Begin ¶ added in v1.5.0
func (b *DebugTransaction) Begin(ctx context.Context) error
func (*DebugTransaction) Commit ¶ added in v1.5.0
func (b *DebugTransaction) Commit(ctx context.Context) error
type Echo ¶
type Echo struct { FuncMap map[string]interface{} RouteDebug bool MiddlewareDebug bool JSONPVarName string Validator Validator FormSliceMaxIndex int // contains filtered or unexported fields }
func NewWithContext ¶
func (*Echo) Add ¶ added in v1.6.0
Add registers a new route for an HTTP method and path with matching handler in the router with optional route-level middleware.
func (*Echo) AddAcceptFormat ¶ added in v1.3.0
func (*Echo) AddBinderValueDecoder ¶ added in v1.6.0
func (e *Echo) AddBinderValueDecoder(name string, decoder BinderValueDecoder) *Echo
func (*Echo) AddBinderValueEncoder ¶ added in v1.6.0
func (e *Echo) AddBinderValueEncoder(name string, encoder BinderValueEncoder) *Echo
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) AppendRouter ¶
AppendRouter append router
func (*Echo) AutoDetectRenderFormat ¶ added in v1.6.0
func (*Echo) CallBinderValueDecoder ¶ added in v1.6.0
func (*Echo) CallBinderValueEncoder ¶ added in v1.6.0
func (*Echo) Clear ¶ added in v1.3.0
func (e *Echo) Clear(middleware ...interface{})
Clear middleware
func (*Echo) ClearPre ¶ added in v1.6.0
func (e *Echo) ClearPre(middleware ...interface{})
ClearPre Clear premiddleware
func (*Echo) DefaultExtension ¶ added in v1.6.0
func (*Echo) DefaultHTTPErrorHandler ¶
DefaultHTTPErrorHandler invokes the default HTTP error handler.
func (*Echo) GetRouteByName ¶ added in v1.12.12
GetRouteByName get route by name
func (*Echo) GetRoutePathByName ¶ added in v1.12.11
GetRoutePathByName get route path by name
func (*Echo) HTTPErrorHandler ¶ added in v1.3.0
func (e *Echo) HTTPErrorHandler() HTTPErrorHandler
HTTPErrorHandler returns the HTTPErrorHandler
func (*Echo) Host ¶ added in v1.6.0
Host creates a new router group for the provided host and optional host-level middleware.
func (*Echo) MakeHandler ¶ added in v1.8.0
Handler Add validateable hanlder about endpoint requests = []interface{}{"POST", H{"k":"v"}} or []interface{}{&myRequestData{},"POST", H{"k":"v"}}
func (*Echo) Match ¶
func (e *Echo) Match(methods []string, path string, h interface{}, middleware ...interface{}) IRouter
Match adds a route > handler to the router for multiple HTTP methods provided.
func (*Echo) MaxRequestBodySize ¶ added in v1.6.0
func (*Echo) MetaHandler ¶
MetaHandler Add meta information about endpoint requests = []interface{}{"POST", H{"k":"v"}} or []interface{}{&myRequestData{},"POST", H{"k":"v"}}
func (*Echo) MetaHandlerWithRequest ¶ added in v1.6.0
func (e *Echo) MetaHandlerWithRequest(m H, handler interface{}, request interface{}, methods ...string) Handler
MetaHandlerWithRequest Add meta information about endpoint methods = []string{"POST", "GET"} or []string{"POST,GET"}
func (*Echo) NamedRoutes ¶
NamedRoutes returns the registered handler name.
func (*Echo) NewContext ¶ added in v1.5.0
func (*Echo) OnHostFound ¶ added in v1.6.0
func (*Echo) ParseHeaderAccept ¶ added in v1.3.9
func (*Echo) Pre ¶
func (e *Echo) Pre(middleware ...interface{})
Pre adds handler to the middleware chain.
func (*Echo) RealIPConfig ¶ added in v1.6.0
func (*Echo) RebuildRouter ¶
RebuildRouter rebuild router
func (*Echo) RemoveFormatRenderer ¶ added in v1.3.7
func (*Echo) RenderDataWrapper ¶ added in v1.6.0
func (e *Echo) RenderDataWrapper() DataWrapper
RenderDataWrapper .
func (*Echo) Renderer ¶ added in v1.3.0
func (e *Echo) Renderer() Renderer
Renderer returns the renderer instance.
func (*Echo) SetAcceptFormats ¶ added in v1.3.0
func (*Echo) SetDefaultExtension ¶ added in v1.6.0
func (*Echo) SetFormSliceMaxIndex ¶ added in v1.6.0
func (*Echo) SetFormatRenderers ¶ added in v1.3.7
func (e *Echo) SetFormatRenderers(formatRenderers map[string]FormatRender) *Echo
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) SetMaxRequestBodySize ¶ added in v1.6.0
func (*Echo) SetMiddlewareWrapper ¶ added in v1.1.0
func (e *Echo) SetMiddlewareWrapper(funcs ...func(interface{}) Middleware)
func (*Echo) SetRenderDataWrapper ¶ added in v1.6.0
func (e *Echo) SetRenderDataWrapper(dataWrapper DataWrapper)
SetRenderDataWrapper .
func (*Echo) SetRenderer ¶
func (e *Echo) SetRenderer(r Renderer)
SetRenderer registers an HTML template renderer. It's invoked by Context.Render().
func (*Echo) SetRewriter ¶ added in v1.6.0
func (*Echo) SetValidator ¶ added in v1.6.0
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 Error ¶ added in v1.6.0
type Error struct { Code pkgCode.Code Message string Zone string Extra H // contains filtered or unexported fields }
func NewErrorWith ¶ added in v1.6.0
func (*Error) SetMessage ¶ added in v1.6.0
type FieldNameFormatter ¶ added in v1.1.0
FieldNameFormatter 结构体字段值映射到表单时,结构体字段名称格式化处理
var ( //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 } //ArrayFieldNameFormatter 格式化函数(struct->form) ArrayFieldNameFormatter 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 } )
func MakeArrayFieldNameFormatter ¶ added in v1.6.0
func MakeArrayFieldNameFormatter(keyFormatter func(string) string) FieldNameFormatter
type FiltersGetter ¶ added in v1.6.0
type FiltersGetter interface {
Filters(Context) []FormDataFilter
}
type FormDataFilter ¶ added in v1.1.0
FormDataFilter 将map映射到结构体时,对名称和值的过滤处理,如果返回的名称为空,则跳过本字段 这里的 key 为结构体字段或map的key层级路径,如果有父级则用星号“*”表示,例如:*.Name
func ExcludeFieldName ¶ added in v1.5.0
func ExcludeFieldName(fieldNames ...string) FormDataFilter
ExcludeFieldName 排除字段
func FormatFieldValue ¶ added in v1.5.0
func FormatFieldValue(formatters map[string]FormDataFilter, keyNormalizerArg ...func(string) string) FormDataFilter
FormatFieldValue 格式化字段值
func IncludeFieldName ¶ added in v1.5.0
func IncludeFieldName(fieldNames ...string) FormDataFilter
IncludeFieldName 包含字段
type FormNameFormatterGetter ¶ added in v1.6.0
type FormNameFormatterGetter interface {
FormNameFormatter(Context) FieldNameFormatter
}
type FormatRender ¶ added in v1.6.0
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 adds handler to the middleware chain.
func (*Group) SetRenderer ¶
func (g *Group) SetRenderer(r Renderer)
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 HandlerFuncWithArg ¶ added in v1.8.0
func (HandlerFuncWithArg[R, W]) Handle ¶ added in v1.8.0
func (h HandlerFuncWithArg[R, W]) Handle(c Context) error
type HandlerFuncs ¶ added in v1.6.0
func (*HandlerFuncs) Register ¶ added in v1.6.0
func (h *HandlerFuncs) Register(key string, fn func(Context) error)
func (*HandlerFuncs) Unregister ¶ added in v1.6.0
func (h *HandlerFuncs) Unregister(keys ...string)
type Host ¶ added in v1.6.0
type Host struct { Router *Router // contains filtered or unexported fields }
type ICore ¶ added in v1.1.0
type ICore interface { RouteRegister URLBuilder RendererRegister Prefixer }
type IsHiddenContext ¶ added in v1.9.5
type IsValidContext ¶ added in v1.9.5
type JSONModifer ¶ added in v1.8.0
type KV ¶ added in v1.1.1
type KV struct { K string V string H H `json:",omitempty" xml:",omitempty"` X interface{} `json:",omitempty" xml:",omitempty"` // contains filtered or unexported fields }
KV 键值对
type KVData ¶ added in v1.1.1
type KVData struct {
// contains filtered or unexported fields
}
KVData 键值对数据(保持顺序)
func (*KVData) GetByIndex ¶ added in v1.7.1
func (*KVData) GetItemByIndex ¶ added in v1.7.1
type KVx ¶ added in v1.7.0
type KVx[X any, Y any] struct { K string V string H H `json:",omitempty" xml:",omitempty"` X X `json:",omitempty" xml:",omitempty"` // contains filtered or unexported fields }
KV 键值对
type KVxData ¶ added in v1.7.0
KVxData 键值对数据(保持顺序)
func (*KVxData[X, Y]) GetByIndex ¶ added in v1.7.1
func (*KVxData[X, Y]) GetItemByIndex ¶ added in v1.7.1
type LangCode ¶ added in v1.6.0
type LangCode interface { String() string // all lowercase characters Normalize() string // lowercase(language)-uppercase(region) Format(regionUppercase bool, separator ...string) string Language() string Region(regionUppercase bool) string }
func NewLangCode ¶ added in v1.6.0
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 }
func (*Mapx) AsFlatSlice ¶ added in v1.4.0
type MetaHandler ¶ added in v1.3.0
type MetaHandler struct { Handler // contains filtered or unexported fields }
func (*MetaHandler) Handle ¶ added in v1.6.0
func (m *MetaHandler) Handle(c Context) error
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 MetaValidator ¶ added in v1.6.0
type MetaValidator interface { MethodGetter FiltersGetter ValueDecodersGetter }
type MethodGetter ¶ added in v1.6.0
type MethodGetter interface {
Methods() []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) AddPreSaveHook ¶ added in v1.6.0
func (n *NopSession) AddPreSaveHook(_ func(Context) error)
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) MustID ¶ added in v1.6.0
func (n *NopSession) MustID() string
func (*NopSession) Options ¶
func (n *NopSession) Options(_ SessionOptions) Sessioner
func (*NopSession) RemoveID ¶ added in v1.6.0
func (n *NopSession) RemoveID(sessionID string) error
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, notReload ...bool) error
func (*NopSession) SetPreSaveHook ¶ added in v1.6.0
func (n *NopSession) SetPreSaveHook(_ ...func(Context) error)
type NopTranslate ¶
type NopTranslate struct {
// contains filtered or unexported fields
}
func (*NopTranslate) E ¶ added in v1.4.3
func (n *NopTranslate) E(format string, args ...interface{}) error
func (*NopTranslate) Lang ¶
func (n *NopTranslate) Lang() LangCode
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{}, _ ...interface{}) 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, debugAndDisableStackAll ...bool) *PanicError
func ParseTemplateError ¶ added in v1.6.0
func ParseTemplateError(err error, sourceContent string) *PanicError
func (*PanicError) AddTrace ¶ added in v1.3.0
func (p *PanicError) AddTrace(trace *Trace, content ...string) *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) ExtractFileSnippets ¶ added in v1.6.0
func (p *PanicError) ExtractFileSnippets(file string, curLineNum int, index int) error
func (*PanicError) ExtractSnippets ¶ added in v1.3.0
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) Parse ¶ added in v1.4.3
func (p *PanicError) Parse(stackSizes ...int) *PanicError
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 pkgCode.Code State string `json:",omitempty" xml:",omitempty"` Info interface{} URL string `json:",omitempty" xml:",omitempty"` 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 RenderContext ¶ added in v1.9.5
type RenderContextWithData ¶ added in v1.13.4
type RenderData ¶ added in v1.6.0
type RenderData struct { Func template.FuncMap Data interface{} Stored param.MapReadonly // contains filtered or unexported fields }
func NewRenderData ¶ added in v1.6.0
func NewRenderData(ctx Context, data interface{}) *RenderData
func (*RenderData) CaptchaForm ¶ added in v1.6.0
func (r *RenderData) CaptchaForm(args ...interface{}) template.HTML
func (*RenderData) Cookie ¶ added in v1.6.0
func (r *RenderData) Cookie() Cookier
func (*RenderData) Decr ¶ added in v1.6.0
func (r *RenderData) Decr(key string, n interface{}, defaults ...interface{}) int64
func (*RenderData) Domain ¶ added in v1.6.0
func (r *RenderData) Domain() string
func (*RenderData) DurationFormat ¶ added in v1.6.0
func (r *RenderData) DurationFormat(t interface{}, args ...string) *com.Durafmt
func (*RenderData) Ext ¶ added in v1.6.0
func (r *RenderData) Ext() string
func (*RenderData) Fetch ¶ added in v1.6.0
func (r *RenderData) Fetch(tmpl string, data interface{}) template.HTML
func (*RenderData) Flash ¶ added in v1.6.0
func (r *RenderData) Flash(keys ...string) interface{}
func (*RenderData) Form ¶ added in v1.6.0
func (r *RenderData) Form(key string, defaults ...string) string
func (*RenderData) FormValues ¶ added in v1.6.0
func (r *RenderData) FormValues(key string) []string
func (*RenderData) Formx ¶ added in v1.6.0
func (r *RenderData) Formx(key string, defaults ...string) param.String
func (*RenderData) FormxValues ¶ added in v1.6.0
func (r *RenderData) FormxValues(key string) param.StringSlice
func (*RenderData) FullRequestURI ¶ added in v1.10.7
func (r *RenderData) FullRequestURI() string
func (*RenderData) Get ¶ added in v1.6.0
func (r *RenderData) Get(key string, defaults ...interface{}) interface{}
func (*RenderData) GetNextURL ¶ added in v1.6.0
func (r *RenderData) GetNextURL(varNames ...string) string
func (*RenderData) GetOtherURL ¶ added in v1.6.0
func (r *RenderData) GetOtherURL(urlStr string, next string) string
func (*RenderData) HasAnyRequest ¶ added in v1.6.0
func (r *RenderData) HasAnyRequest() bool
func (*RenderData) Header ¶ added in v1.6.0
func (r *RenderData) Header() engine.Header
func (*RenderData) Incr ¶ added in v1.6.0
func (r *RenderData) Incr(key string, n interface{}, defaults ...interface{}) int64
func (*RenderData) IsHidden ¶ added in v1.9.5
func (r *RenderData) IsHidden(a IsHiddenContext) bool
func (*RenderData) IsValid ¶ added in v1.9.5
func (r *RenderData) IsValid(a IsValidContext) bool
func (*RenderData) Lang ¶ added in v1.6.0
func (r *RenderData) Lang() LangCode
func (*RenderData) MakeURL ¶ added in v1.6.0
func (r *RenderData) MakeURL(h interface{}, args ...interface{}) string
func (*RenderData) Now ¶ added in v1.6.0
func (r *RenderData) Now() *com.Time
func (*RenderData) Param ¶ added in v1.6.0
func (r *RenderData) Param(key string, defaults ...string) string
func (*RenderData) Paramx ¶ added in v1.6.0
func (r *RenderData) Paramx(key string, defaults ...string) param.String
func (*RenderData) Path ¶ added in v1.6.0
func (r *RenderData) Path() string
func (*RenderData) Port ¶ added in v1.6.0
func (r *RenderData) Port() int
func (*RenderData) Prefix ¶ added in v1.6.0
func (r *RenderData) Prefix() string
func (*RenderData) Queries ¶ added in v1.6.0
func (r *RenderData) Queries() map[string][]string
func (*RenderData) Query ¶ added in v1.6.0
func (r *RenderData) Query(key string, defaults ...string) string
func (*RenderData) QueryValues ¶ added in v1.6.0
func (r *RenderData) QueryValues(key string) []string
func (*RenderData) Queryx ¶ added in v1.6.0
func (r *RenderData) Queryx(key string, defaults ...string) param.String
func (*RenderData) QueryxValues ¶ added in v1.6.0
func (r *RenderData) QueryxValues(key string) param.StringSlice
func (*RenderData) Referer ¶ added in v1.6.0
func (r *RenderData) Referer() string
func (*RenderData) Render ¶ added in v1.9.5
func (r *RenderData) Render(a RenderContext) template.HTML
func (*RenderData) RenderWithData ¶ added in v1.13.4
func (r *RenderData) RenderWithData(a RenderContextWithData, data interface{}) template.HTML
func (*RenderData) RequestURI ¶ added in v1.6.0
func (r *RenderData) RequestURI() string
func (*RenderData) ReturnToCurrentURL ¶ added in v1.6.0
func (r *RenderData) ReturnToCurrentURL(varNames ...string) string
func (*RenderData) RootPrefix ¶ added in v1.10.8
func (r *RenderData) RootPrefix() string
func (*RenderData) Scheme ¶ added in v1.6.0
func (r *RenderData) Scheme() string
func (*RenderData) Session ¶ added in v1.6.0
func (r *RenderData) Session() Sessioner
func (*RenderData) Set ¶ added in v1.6.0
func (r *RenderData) Set(key string, value interface{}) string
func (*RenderData) Site ¶ added in v1.6.0
func (r *RenderData) Site() string
func (*RenderData) SiteURI ¶ added in v1.6.0
func (r *RenderData) SiteURI() string
func (*RenderData) T ¶ added in v1.6.0
func (r *RenderData) T(format string, args ...interface{}) string
func (*RenderData) ThemeColor ¶ added in v1.6.0
func (r *RenderData) ThemeColor() string
func (*RenderData) TimeAgo ¶ added in v1.6.0
func (r *RenderData) TimeAgo(v interface{}, options ...string) string
func (*RenderData) TsHumanize ¶ added in v1.6.0
func (r *RenderData) TsHumanize(startTime interface{}, endTime ...interface{}) string
func (*RenderData) URI ¶ added in v1.6.0
func (r *RenderData) URI() string
func (*RenderData) URL ¶ added in v1.6.0
func (r *RenderData) URL() engine.URL
func (*RenderData) UnixTime ¶ added in v1.6.0
func (r *RenderData) UnixTime() int64
func (*RenderData) WithNextURL ¶ added in v1.6.0
func (r *RenderData) WithNextURL(urlStr string, varNames ...string) string
type Renderer ¶
type Renderer interface { Render(w io.Writer, name string, data interface{}, c Context) error RenderBy(w io.Writer, name string, content func(string) ([]byte, error), data interface{}, c Context) error }
Renderer is the interface that wraps the Render method.
type RendererRegister ¶ added in v1.4.3
type RendererRegister interface {
SetRenderer(Renderer)
}
type RequestValidator ¶ added in v1.6.0
type RequestValidator func() MetaValidator
type Route ¶
type Route struct { Host string Method string Path string Handler Handler `json:"-" xml:"-"` Name string Format string Params []string //param names Prefix string Meta H // contains filtered or unexported fields }
type RouteRegister ¶ added in v1.1.0
type RouteRegister interface { MiddlewareRegister Group(prefix string, middleware ...interface{}) *Group Any(path string, h interface{}, middleware ...interface{}) IRouter Route(methods string, path string, h interface{}, middleware ...interface{}) IRouter Match(methods []string, path string, h interface{}, middleware ...interface{}) IRouter Connect(path string, h interface{}, m ...interface{}) IRouter Delete(path string, h interface{}, m ...interface{}) IRouter Get(path string, h interface{}, m ...interface{}) IRouter Head(path string, h interface{}, m ...interface{}) IRouter Options(path string, h interface{}, m ...interface{}) IRouter Patch(path string, h interface{}, m ...interface{}) IRouter Post(path string, h interface{}, m ...interface{}) IRouter Put(path string, h interface{}, m ...interface{}) IRouter Trace(path string, h interface{}, m ...interface{}) IRouter Static(prefix, root string) File(path, file string) Prefix() string }
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Add ¶
Add 添加路由 method: 方法(GET/POST/PUT/DELETE/PATCH/OPTIONS/HEAD/CONNECT/TRACE) prefix: group前缀 path: 路径(含前缀) h: Handler name: Handler名 meta: meta数据
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 NewSessionOptions ¶ added in v1.4.0
func NewSessionOptions(engine string, name string, args ...*CookieOptions) *SessionOptions
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, notReload ...bool) error ID() string MustID() string RemoveID(sessionID string) error // 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 AddPreSaveHook(func(Context) error) SetPreSaveHook(...func(Context) 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 ToConversion ¶
type ToConversion interface {
ToString() string
}
ToConversion a struct implements this interface can be convert from struct to template variable Not Implemented
type Transaction ¶ added in v1.3.9
type Transaction interface { Begin(ctx context.Context) error Rollback(ctx context.Context) error Commit(ctx context.Context) error End(ctx context.Context, succeed bool) error }
var ( DefaultNopTransaction = NewTransaction(nil) DefaultDebugTransaction Transaction = &DebugTransaction{} )
type Translator ¶
type Translator interface { T(format string, args ...interface{}) string E(format string, args ...interface{}) error Lang() LangCode }
var DefaultNopTranslate Translator = &NopTranslate{
code: langCode{
language: `en`,
},
}
type URLBuilder ¶ added in v1.1.0
type URLBuilder interface {
URL(interface{}, ...interface{}) string
}
type UnwrapTransaction ¶ added in v1.6.0
type UnwrapTransaction interface {
Unwrap() Transaction
}
type ValidateResult ¶ added in v1.3.0
type ValidateResult interface { Ok() bool Error() string Unwrap() error Field() string Raw() interface{} //setter SetError(error) ValidateResult SetField(string) ValidateResult SetRaw(interface{}) ValidateResult AsError() error }
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 ...interface{}) ValidateResult
Validate 此处支持两种用法: 1. Validate(表单字段名, 表单值, 验证规则名) 2. Validate(结构体实例, 要验证的结构体字段1,要验证的结构体字段2) Validate(结构体实例) 代表验证所有带“valid”标签的字段
type Validator ¶
type Validator interface {
Validate(i interface{}, args ...interface{}) 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) AsError ¶ added in v1.6.0
func (v *ValidatorResult) AsError() 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
func (*ValidatorResult) Unwrap ¶ added in v1.6.0
func (v *ValidatorResult) Unwrap() error
type ValueDecodersGetter ¶ added in v1.6.0
type ValueDecodersGetter interface {
ValueDecoders(Context) BinderValueCustomDecoders
}
type ValueEncodersGetter ¶ added in v1.6.0
type ValueEncodersGetter interface {
ValueEncoders(Context) BinderValueCustomEncoders
}
type ValueStringersGetter ¶ added in v1.6.0
type ValueStringersGetter interface {
ValueStringers(Context) param.StringerMap
}
type XContext ¶ added in v1.11.0
type XContext struct { Translator events.Emitterer // contains filtered or unexported fields }
func (*XContext) AddHostParam ¶ added in v1.11.0
func (*XContext) AddPreResponseHook ¶ added in v1.11.0
func (*XContext) Attachment ¶ added in v1.11.0
func (*XContext) Bind ¶ added in v1.11.0
func (c *XContext) Bind(i interface{}, filter ...FormDataFilter) error
Bind binds the request body into specified type `i`. The default binder does it based on Content-Type header.
func (*XContext) BindAndValidate ¶ added in v1.11.0
func (c *XContext) BindAndValidate(i interface{}, filter ...FormDataFilter) error
func (*XContext) BindAndValidateWithDecoder ¶ added in v1.11.0
func (c *XContext) BindAndValidateWithDecoder(i interface{}, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error
func (*XContext) BindWithDecoder ¶ added in v1.11.0
func (c *XContext) BindWithDecoder(i interface{}, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error
func (*XContext) CacheableAttachment ¶ added in v1.11.0
func (*XContext) CacheableFile ¶ added in v1.11.0
func (*XContext) CookieOptions ¶ added in v1.11.0
func (c *XContext) CookieOptions() *CookieOptions
func (*XContext) DefaultExtension ¶ added in v1.11.0
func (*XContext) Error ¶ added in v1.11.0
Error invokes the registered HTTP error handler. Generally used by middleware.
func (*XContext) File ¶ added in v1.11.0
func (c *XContext) File(file string, fs ...http.FileSystem) error
func (*XContext) FireHostFound ¶ added in v1.11.0
func (*XContext) FormValues ¶ added in v1.11.0
func (*XContext) FormxValues ¶ added in v1.11.0
func (c *XContext) FormxValues(name string) param.StringSlice
func (*XContext) FullRequestURI ¶ added in v1.11.0
func (*XContext) HasAnyRequest ¶ added in v1.11.0
HasAnyRequest 是否提交了参数
func (*XContext) Host ¶ added in v1.11.0
Host returns host name. if no host info in request, return localhost.
func (*XContext) HostParamNames ¶ added in v1.11.0
func (*XContext) HostParamValues ¶ added in v1.11.0
func (*XContext) IsUpload ¶ added in v1.11.0
IsUpload returns boolean of whether file uploads in this request or not..
func (*XContext) IsValidCache ¶ added in v1.11.0
func (*XContext) IsWebsocket ¶ added in v1.11.0
IsWebsocket returns boolean of this request is in webSocket.
func (*XContext) JSONP ¶ added in v1.11.0
JSONP sends a JSONP response with status code. It uses `callback` to construct the JSONP payload.
func (*XContext) MapForm ¶ added in v1.11.0
MapForm 映射表单数据到结构体 ParseStruct mapping forms' name and values to struct's field For example:
<form> <input name=`user.id`/> <input name=`user.name`/> <input name=`user.age`/> </form> type User struct { Id int64 Name string Age string } var user User err := c.MapForm(&user,`user`)
func (*XContext) MustBind ¶ added in v1.11.0
func (c *XContext) MustBind(i interface{}, filter ...FormDataFilter) error
func (*XContext) MustBindAndValidate ¶ added in v1.11.0
func (c *XContext) MustBindAndValidate(i interface{}, filter ...FormDataFilter) error
func (*XContext) MustBindAndValidateWithDecoder ¶ added in v1.11.0
func (c *XContext) MustBindAndValidateWithDecoder(i interface{}, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error
func (*XContext) MustBindWithDecoder ¶ added in v1.11.0
func (c *XContext) MustBindWithDecoder(i interface{}, valueDecoders BinderValueCustomDecoders, filter ...FormDataFilter) error
func (*XContext) NewErrorWith ¶ added in v1.11.0
func (*XContext) NoContent ¶ added in v1.11.0
NoContent sends a response with no body and a status code.
func (*XContext) NotModified ¶ added in v1.11.0
func (*XContext) OnHostFound ¶ added in v1.11.0
func (*XContext) ParamNames ¶ added in v1.11.0
func (*XContext) ParamValues ¶ added in v1.11.0
func (*XContext) PjaxContainer ¶ added in v1.11.0
func (*XContext) Port ¶ added in v1.11.0
Port returns request client port. when error or empty, return 80.
func (*XContext) PrintFuncs ¶ added in v1.11.0
func (c *XContext) PrintFuncs()
func (*XContext) Protocol ¶ added in v1.11.0
Protocol returns request protocol name, such as HTTP/1.1 .
func (*XContext) QueryValues ¶ added in v1.11.0
func (*XContext) QueryxValues ¶ added in v1.11.0
func (c *XContext) QueryxValues(name string) param.StringSlice
func (*XContext) Render ¶ added in v1.11.0
Render renders a template with data and sends a text/html response with status code. Templates can be registered using `Echo.SetRenderer()`.
func (*XContext) RenderDataWrapper ¶ added in v1.11.0
func (c *XContext) RenderDataWrapper() DataWrapper
RenderDataWrapper .
func (*XContext) RequestURI ¶ added in v1.11.0
func (*XContext) ResetFuncs ¶ added in v1.11.0
func (*XContext) ResolveContentType ¶ added in v1.11.0
ResolveContentType Get the content type. e.g. From `multipart/form-data; boundary=--` to `multipart/form-data` If none is specified, returns `text/html` by default.
func (*XContext) ResolveFormat ¶ added in v1.11.0
ResolveFormat maps the request's Accept MIME type declaration to a Request.Format attribute, specifically `html`, `xml`, `json`, or `txt`, returning a default of `html` when Accept header cannot be mapped to a value above.
func (*XContext) SaveUploadedFile ¶ added in v1.11.0
func (c *XContext) SaveUploadedFile(fieldName string, saveAbsPath string, saveFileName ...func(*multipart.FileHeader) (string, error)) (*multipart.FileHeader, error)
func (*XContext) SaveUploadedFileToWriter ¶ added in v1.11.0
func (*XContext) SaveUploadedFiles ¶ added in v1.11.0
func (*XContext) SaveUploadedFilesToWriter ¶ added in v1.11.0
func (*XContext) ServeCallbackContent ¶ added in v1.11.0
func (*XContext) ServeContent ¶ added in v1.11.0
func (*XContext) SessionOptions ¶ added in v1.11.0
func (c *XContext) SessionOptions() *SessionOptions
func (*XContext) SetCacheHeader ¶ added in v1.11.0
func (*XContext) SetCookieOptions ¶ added in v1.11.0
func (c *XContext) SetCookieOptions(opts *CookieOptions)
func (*XContext) SetDefaultExtension ¶ added in v1.11.0
func (*XContext) SetEmitterer ¶ added in v1.11.0
func (*XContext) SetHostParamNames ¶ added in v1.11.0
func (*XContext) SetHostParamValues ¶ added in v1.11.0
func (*XContext) SetParamNames ¶ added in v1.11.0
func (*XContext) SetParamValues ¶ added in v1.11.0
func (*XContext) SetPreResponseHook ¶ added in v1.11.0
func (*XContext) SetRenderDataWrapper ¶ added in v1.11.0
func (c *XContext) SetRenderDataWrapper(dataWrapper DataWrapper)
SetRenderDataWrapper .
func (*XContext) SetRenderer ¶ added in v1.11.0
func (c *XContext) SetRenderer(r Renderer)
SetRenderer registers an HTML template renderer.
func (*XContext) SetSessionOptions ¶ added in v1.11.0
func (c *XContext) SetSessionOptions(opts *SessionOptions)
func (*XContext) SetSessioner ¶ added in v1.11.0
func (*XContext) SetTransaction ¶ added in v1.11.0
func (c *XContext) SetTransaction(t Transaction)
func (*XContext) SetTranslator ¶ added in v1.11.0
func (c *XContext) SetTranslator(t Translator)
func (*XContext) SetValidator ¶ added in v1.11.0
func (*XContext) StdContext ¶ added in v1.11.0
func (*XContext) ToParamString ¶ added in v1.11.0
func (*XContext) ToStringSlice ¶ added in v1.11.0
func (c *XContext) ToStringSlice(v []string) param.StringSlice
func (*XContext) Transaction ¶ added in v1.11.0
func (c *XContext) Transaction() Transaction
func (*XContext) WithContext ¶ added in v1.11.0
func (*XContext) WithFormatExtension ¶ added in v1.11.0
type XMLModifer ¶ added in v1.8.0
Source Files ¶
- binder.go
- binder_errors.go
- binder_filter.go
- binder_formatter.go
- binder_stringer.go
- binder_toform.go
- binder_tostruct.go
- constant.go
- context.go
- context_accept.go
- context_store.go
- context_x_base.go
- context_x_request.go
- context_x_response.go
- context_x_session.go
- context_x_store.go
- context_x_transaction.go
- cookie.go
- data.go
- data_kv.go
- data_kv_option.go
- data_kv_x.go
- data_kv_x_option .go
- echo.go
- echo_host.go
- error.go
- event.go
- group.go
- hashmap.go
- helper.go
- host.go
- meta.go
- middleware.go
- register.go
- render_data.go
- router.go
- sessioner.go
- transaction.go
- translator.go
- validator.go
- variable.go
- variable_default.go
- wrapper.go
Directories ¶
Path | Synopsis |
---|---|
encoding
|
|
handler
|
|
ratelimit/config
Package config provides data structure to configure rate-limiter.
|
Package config provides data structure to configure rate-limiter. |
render
Copyright 2016 Wenhui Shen <www.webx.top>
|
Copyright 2016 Wenhui Shen <www.webx.top> |
* | |