Documentation ¶
Overview ¶
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func ContentTypeByExtension(name string) (t string)
- func DefaultSkipper(c Context) bool
- func FormNames(s string) []string
- func HandlerName(h interface{}) string
- func Methods() []string
- func NamedStructMap(e *Echo, m interface{}, data map[string][]string, topName string, ...) error
- func StructToForm(ctx Context, m interface{}, topName string, ...)
- type Binder
- type Context
- type Cookie
- type CookieOptions
- type Cookier
- type Data
- type Echo
- func (e *Echo) AddHandlerWrapper(funcs ...func(interface{}) Handler)
- func (e *Echo) AddMiddlewareWrapper(funcs ...func(interface{}) Middleware)
- func (e *Echo) Any(path string, h interface{}, middleware ...interface{})
- func (e *Echo) AppendRouter(routes []*Route)
- func (e *Echo) Binder() Binder
- func (e *Echo) Connect(path string, h interface{}, m ...interface{})
- func (e *Echo) Debug() bool
- func (e *Echo) DefaultHTTPErrorHandler(err error, c Context)
- func (e *Echo) Delete(path string, h interface{}, m ...interface{})
- func (e *Echo) Engine() engine.Engine
- func (e *Echo) Get(path string, h interface{}, m ...interface{})
- func (e *Echo) Group(prefix string, m ...interface{}) (g *Group)
- func (e *Echo) Head(path string, h interface{}, m ...interface{})
- func (e *Echo) Logger() logger.Logger
- func (e *Echo) Match(methods []string, path string, h interface{}, middleware ...interface{})
- func (e *Echo) MetaHandler(m H, handler interface{}) interface{}
- func (e *Echo) MetaMiddleware(m H, middleware interface{}) interface{}
- func (e *Echo) NamedRoutes() map[string][]int
- func (e *Echo) Options(path string, h interface{}, m ...interface{})
- func (e *Echo) Patch(path string, h interface{}, m ...interface{})
- func (e *Echo) Post(path string, h interface{}, m ...interface{})
- func (e *Echo) Pre(middleware ...interface{})
- func (e *Echo) PreUse(middleware ...interface{})
- func (e *Echo) Prefix() string
- func (e *Echo) Put(path string, h interface{}, m ...interface{})
- func (e *Echo) RebuildRouter(args ...[]*Route)
- func (e *Echo) Route(methods string, path string, h interface{}, middleware ...interface{})
- func (e *Echo) Router() *Router
- func (e *Echo) Routes() []*Route
- func (e *Echo) Run(eng engine.Engine, handler ...engine.Handler)
- func (e *Echo) ServeHTTP(req engine.Request, res engine.Response)
- func (e *Echo) SetBinder(b Binder)
- func (e *Echo) SetDebug(on bool)
- func (e *Echo) SetHTTPErrorHandler(h HTTPErrorHandler)
- func (e *Echo) SetHandlerWrapper(funcs ...func(interface{}) Handler)
- func (e *Echo) SetLogger(l logger.Logger)
- func (e *Echo) SetMiddlewareWrapper(funcs ...func(interface{}) Middleware)
- func (e *Echo) SetRenderer(r Renderer)
- func (e *Echo) Stop() error
- func (e *Echo) Trace(path string, h interface{}, m ...interface{})
- func (e *Echo) URI(handler interface{}, params ...interface{}) string
- func (e *Echo) URL(h interface{}, params ...interface{}) string
- func (e *Echo) Use(middleware ...interface{})
- func (e *Echo) ValidHandler(v interface{}) (h Handler)
- func (e *Echo) ValidMiddleware(v interface{}) (m Middleware)
- type FieldNameFormatter
- type FormDataFilter
- type FromConversion
- type Group
- func (g *Group) Any(path string, h interface{}, middleware ...interface{})
- func (g *Group) Connect(path string, h interface{}, m ...interface{})
- func (g *Group) Delete(path string, h interface{}, m ...interface{})
- func (g *Group) Get(path string, h interface{}, m ...interface{})
- func (g *Group) Group(prefix string, m ...interface{}) *Group
- func (g *Group) Head(path string, h interface{}, m ...interface{})
- func (g *Group) Match(methods []string, path string, h interface{}, middleware ...interface{})
- func (g *Group) Options(path string, h interface{}, m ...interface{})
- func (g *Group) Patch(path string, h interface{}, m ...interface{})
- func (g *Group) Post(path string, h interface{}, m ...interface{})
- func (g *Group) Pre(middleware ...interface{})
- func (g *Group) PreUse(middleware ...interface{})
- func (g *Group) Prefix() string
- func (g *Group) Put(path string, h interface{}, m ...interface{})
- func (g *Group) Route(methods string, path string, h interface{}, middleware ...interface{})
- func (g *Group) SetRenderer(r Renderer)
- func (g *Group) Trace(path string, h interface{}, m ...interface{})
- func (g *Group) URL(h interface{}, params ...interface{}) string
- func (g *Group) Use(middleware ...interface{})
- type H
- type HTTPError
- type HTTPErrorHandler
- type HandleNamer
- type Handler
- type HandlerFunc
- type ICore
- 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 NopSession
- func (n *NopSession) AddFlash(_ interface{}, _ ...string) Sessioner
- func (n *NopSession) Clear() Sessioner
- func (n *NopSession) Delete(name string) Sessioner
- func (n *NopSession) Flashes(_ ...string) []interface{}
- func (n *NopSession) Get(name string) interface{}
- func (n *NopSession) Id() string
- func (n *NopSession) Options(_ SessionOptions) Sessioner
- func (n *NopSession) Save() error
- func (n *NopSession) Set(name string, value interface{}) Sessioner
- func (n *NopSession) SetId(id string) Sessioner
- type NopTranslate
- type Renderer
- type Route
- type RouteRegister
- type Router
- type SessionOptions
- type Sessioner
- type Skipper
- type ToConversion
- type Translator
- type URLBuilder
- type Validator
Constants ¶
const ( // CONNECT HTTP method CONNECT = "CONNECT" // DELETE HTTP method DELETE = "DELETE" // GET HTTP method GET = "GET" // HEAD HTTP method HEAD = "HEAD" // OPTIONS HTTP method OPTIONS = "OPTIONS" // PATCH HTTP method PATCH = "PATCH" // POST HTTP method POST = "POST" // PUT HTTP method PUT = "PUT" // TRACE HTTP method TRACE = "TRACE" MIMEApplicationJSON = "application/json" MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + CharsetUTF8 MIMEApplicationJavaScript = "application/javascript" MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + CharsetUTF8 MIMEApplicationXML = "application/xml" MIMEApplicationXMLCharsetUTF8 = MIMEApplicationXML + "; " + CharsetUTF8 MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEApplicationProtobuf = "application/protobuf" MIMEApplicationMsgpack = "application/msgpack" MIMETextHTML = "text/html" MIMETextHTMLCharsetUTF8 = MIMETextHTML + "; " + CharsetUTF8 MIMETextPlain = "text/plain" MIMETextPlainCharsetUTF8 = MIMETextPlain + "; " + CharsetUTF8 MIMEMultipartForm = "multipart/form-data" MIMEOctetStream = "application/octet-stream" MIMEEventStream = "text/event-stream" CharsetUTF8 = "charset=utf-8" HeaderAcceptEncoding = "Accept-Encoding" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderIfModifiedSince = "If-Modified-Since" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXForwardedFor = "X-Forwarded-For" HeaderXRealIP = "X-Real-IP" HeaderServer = "Server" HeaderOrigin = "Origin" 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" )
Variables ¶
var ( DefaultNopFilter FormDataFilter = func(k string, v []string) (string, []string) { return k, v } DefaultFieldNameFormatter FieldNameFormatter = func(topName, fieldName string) string { var fName string if len(topName) == 0 { fName = fieldName } else { fName = topName + "." + fieldName } return fName } LowerCaseFirstLetter FieldNameFormatter = func(topName, fieldName string) string { var fName string s := []rune(fieldName) if len(s) > 0 { s[0] = unicode.ToLower(s[0]) fieldName = string(s) } if len(topName) == 0 { fName = fieldName } else { fName = topName + "." + fieldName } return fName } )
var ( ErrUnsupportedMediaType error = NewHTTPError(http.StatusUnsupportedMediaType) ErrNotFound error = NewHTTPError(http.StatusNotFound) ErrStatusRequestEntityTooLarge error = NewHTTPError(http.StatusRequestEntityTooLarge) ErrMethodNotAllowed error = NewHTTPError(http.StatusMethodNotAllowed) ErrRendererNotRegistered = errors.New("renderer not registered") ErrInvalidRedirectCode = errors.New("invalid redirect status code") NotFoundHandler = HandlerFunc(func(c Context) error { return ErrNotFound }) MethodNotAllowedHandler = HandlerFunc(func(c Context) error { return ErrMethodNotAllowed }) )
var DefaultHtmlFilter = func(v string) (r string) {
return v
}
Functions ¶
func ContentTypeByExtension ¶
ContentTypeByExtension returns the MIME type associated with the file based on its extension. It returns `application/octet-stream` incase MIME type is not found.
func DefaultSkipper ¶
defaultSkipper returns false which processes the middleware.
func NamedStructMap ¶
func StructToForm ¶ added in v1.1.0
func StructToForm(ctx Context, m interface{}, topName string, fieldNameFormatter FieldNameFormatter)
Types ¶
type Binder ¶
type Binder interface { Bind(interface{}, Context, ...FormDataFilter) error MustBind(interface{}, Context, ...FormDataFilter) error }
Binder is the interface that wraps the Bind method.
type Context ¶
type Context interface { context.Context Translator SetTranslator(Translator) Request() engine.Request Response() engine.Response Handle(Context) error Logger() logger.Logger Object() *xContext Echo() *Echo Reset(engine.Request, engine.Response) Path() string P(int) string Param(string) string // ParamNames returns path parameter names. ParamNames() []string SetParamNames(...string) ParamValues() []string SetParamValues(values ...string) // Queries returns the query parameters as map. It is an alias for `engine.URL#Query()`. Queries() map[string][]string QueryValues(string) []string Query(string) string Form(string) string FormValues(string) []string // Forms returns the form parameters as map. It is an alias for `engine.Request#Form().All()`. Forms() map[string][]string // Param+ Px(int) param.String Paramx(string) param.String Queryx(string) param.String Formx(string) param.String // string to param.String Atop(string) param.String Set(string, interface{}) Get(string) interface{} Stored() store Bind(interface{}, ...FormDataFilter) error MustBind(interface{}, ...FormDataFilter) error Render(string, interface{}, ...int) error HTML(string, ...int) error String(string, ...int) error Blob([]byte, ...int) error JSON(interface{}, ...int) error JSONBlob([]byte, ...int) error JSONP(string, interface{}, ...int) error XML(interface{}, ...int) error XMLBlob([]byte, ...int) error Stream(func(io.Writer) bool) SSEvent(string, chan interface{}) error File(string) error Attachment(io.ReadSeeker, string) error NoContent(...int) error Redirect(string, ...int) error Error(err error) SetCode(int) Code() int NewData(...interface{}) *Data // ServeContent sends static content from `io.Reader` and handles caching // via `If-Modified-Since` request header. It automatically sets `Content-Type` // and `Last-Modified` response headers. ServeContent(io.ReadSeeker, string, time.Time) error SetFunc(string, interface{}) GetFunc(string) interface{} ResetFuncs(map[string]interface{}) Funcs() map[string]interface{} Fetch(string, interface{}) ([]byte, error) SetRenderer(Renderer) SetCookieOptions(*CookieOptions) CookieOptions() *CookieOptions NewCookie(string, string) *Cookie Cookie() Cookier GetCookie(string) string SetCookie(string, string, ...interface{}) SetSessionOptions(*SessionOptions) SessionOptions() *SessionOptions SetSessioner(Sessioner) Session() Sessioner Flash(...string) interface{} Header(string) string IsAjax() bool Method() string Format() string IsPost() bool IsGet() bool IsPut() bool IsDel() bool IsHead() bool IsPatch() bool IsOptions() bool IsSecure() bool IsWebsocket() bool IsUpload() bool ResolveContentType() string WithFormatExtension(bool) ResolveFormat() string Protocol() string Site() string Scheme() string Domain() string Host() string Proxy() []string Referer() string Port() int SaveUploadedFile(string, string, ...string) (*multipart.FileHeader, error) SaveUploadedFileToWriter(string, io.Writer) (*multipart.FileHeader, error) AddPreResponseHook(func() error) Context SetPreResponseHook(...func() error) Context }
Context represents context for the current request. It holds request and response objects, path parameters, data and registered handler.
type CookieOptions ¶
type Cookier ¶
func NewCookier ¶
type Data ¶
type Data struct { Code int Info interface{} Zone interface{} `json:",omitempty" xml:",omitempty"` Data interface{} `json:",omitempty" xml:",omitempty"` }
type Echo ¶
type Echo struct { FuncMap map[string]interface{} // contains filtered or unexported fields }
func NewWithContext ¶
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) DefaultHTTPErrorHandler ¶
DefaultHTTPErrorHandler invokes the default HTTP error handler.
func (*Echo) MetaHandler ¶
MetaHandler Add meta information about endpoint
func (*Echo) MetaMiddleware ¶
MetaMiddleware Add meta information about endpoint
func (*Echo) NamedRoutes ¶
NamedRoutes returns the registered handler name.
func (*Echo) PreUse ¶
func (e *Echo) PreUse(middleware ...interface{})
PreUse adds handler to the middleware chain.
func (*Echo) RebuildRouter ¶
RebuildRouter rebuild router
func (*Echo) SetHTTPErrorHandler ¶
func (e *Echo) SetHTTPErrorHandler(h HTTPErrorHandler)
SetHTTPErrorHandler registers a custom Echo.HTTPErrorHandler.
func (*Echo) SetHandlerWrapper ¶ added in v1.1.0
func (*Echo) SetMiddlewareWrapper ¶ added in v1.1.0
func (e *Echo) SetMiddlewareWrapper(funcs ...func(interface{}) Middleware)
func (*Echo) SetRenderer ¶
SetRenderer registers an HTML template renderer. It's invoked by Context.Render().
func (*Echo) Use ¶
func (e *Echo) Use(middleware ...interface{})
Use adds handler to the middleware chain.
func (*Echo) ValidHandler ¶
func (*Echo) ValidMiddleware ¶
func (e *Echo) ValidMiddleware(v interface{}) (m Middleware)
type FieldNameFormatter ¶ added in v1.1.0
type FormDataFilter ¶ added in v1.1.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) SetRenderer ¶
type H ¶
type H map[string]interface{}
func (H) MarshalXML ¶
MarshalXML allows type H to be used with xml.Marshal
type HTTPError ¶
func NewHTTPError ¶
type HTTPErrorHandler ¶
HTTPErrorHandler is a centralized HTTP error handler.
type HandleNamer ¶
type HandleNamer interface {
HandleName() string
}
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
func (HandlerFunc) SetMeta ¶
func (h HandlerFunc) SetMeta(e *Echo, meta H) HandlerFunc
type ICore ¶ added in v1.1.0
type ICore interface { RouteRegister MiddlewareRegister URLBuilder }
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
func (MiddlewareFunc) SetMeta ¶
func (m MiddlewareFunc) SetMeta(e *Echo, meta H) MiddlewareFunc
type MiddlewareFuncd ¶
type MiddlewareFuncd func(Handler) HandlerFunc
func (MiddlewareFuncd) Handle ¶
func (m MiddlewareFuncd) Handle(h Handler) Handler
func (MiddlewareFuncd) SetMeta ¶
func (m MiddlewareFuncd) SetMeta(e *Echo, meta H) MiddlewareFuncd
type MiddlewareRegister ¶ added in v1.1.0
type MiddlewareRegister interface { Use(middleware ...interface{}) Pre(middleware ...interface{}) }
type NopSession ¶
type NopSession struct { }
func (*NopSession) AddFlash ¶
func (n *NopSession) AddFlash(_ interface{}, _ ...string) Sessioner
func (*NopSession) Clear ¶
func (n *NopSession) Clear() Sessioner
func (*NopSession) Delete ¶
func (n *NopSession) Delete(name string) Sessioner
func (*NopSession) Flashes ¶
func (n *NopSession) Flashes(_ ...string) []interface{}
func (*NopSession) Get ¶
func (n *NopSession) Get(name string) interface{}
func (*NopSession) Id ¶
func (n *NopSession) Id() string
func (*NopSession) Options ¶
func (n *NopSession) Options(_ SessionOptions) Sessioner
func (*NopSession) Save ¶
func (n *NopSession) Save() error
func (*NopSession) Set ¶
func (n *NopSession) Set(name string, value interface{}) Sessioner
func (*NopSession) SetId ¶
func (n *NopSession) SetId(id string) Sessioner
type NopTranslate ¶
type NopTranslate struct {
// contains filtered or unexported fields
}
func (*NopTranslate) Lang ¶
func (n *NopTranslate) Lang() string
func (*NopTranslate) T ¶
func (n *NopTranslate) T(format string, args ...interface{}) string
type RouteRegister ¶ added in v1.1.0
type RouteRegister interface { Any(path string, h interface{}, middleware ...interface{}) Route(methods string, path string, h interface{}, middleware ...interface{}) Match(methods []string, path string, h interface{}, middleware ...interface{}) Connect(path string, h interface{}, m ...interface{}) Delete(path string, h interface{}, m ...interface{}) Get(path string, h interface{}, m ...interface{}) Head(path string, h interface{}, m ...interface{}) Options(path string, h interface{}, m ...interface{}) Patch(path string, h interface{}, m ...interface{}) Post(path string, h interface{}, m ...interface{}) Put(path string, h interface{}, m ...interface{}) Trace(path string, h interface{}, m ...interface{}) }
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.
type Sessioner ¶
type Sessioner interface { // Get returns the session value associated to the given key. Get(key string) interface{} // Set sets the session value associated to the given key. Set(key string, val interface{}) Sessioner SetId(id string) Sessioner Id() string // Delete removes the session value associated to the given key. Delete(key string) Sessioner // Clear deletes all values in the session. Clear() Sessioner // AddFlash adds a flash message to the session. // A single variadic argument is accepted, and it is optional: it defines the flash key. // If not defined "_flash" is used by default. AddFlash(value interface{}, vars ...string) Sessioner // Flashes returns a slice of flash messages from the session. // A single variadic argument is accepted, and it is optional: it defines the flash key. // If not defined "_flash" is used by default. Flashes(vars ...string) []interface{} Options(SessionOptions) Sessioner // Save saves all sessions used during the current request. Save() error }
Sessioner Wraps thinly gorilla-session methods. Session stores the values and optional configuration for a session.
var ( DefaultNopSession Sessioner = &NopSession{} DefaultSessionOptions = &SessionOptions{ Engine: `cookie`, Name: `SID`, CookieOptions: &CookieOptions{}, } )
type Skipper ¶
Skipper defines a function to skip middleware. Returning true skips processing the middleware.
type ToConversion ¶
type ToConversion interface {
ToString() string
}
ToConversion a struct implements this interface can be convert from struct to template variable Not Implemented
type Translator ¶
var DefaultNopTranslate Translator = &NopTranslate{language: `en`}
type URLBuilder ¶ added in v1.1.0
type URLBuilder interface {
URL(interface{}, ...interface{}) string
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
handler
|
|
mvc/static/minify
Package cssmin minifies CSS.
|
Package cssmin minifies CSS. |
ratelimit/config
Package config provides data structure to configure rate-limiter.
|
Package config provides data structure to configure rate-limiter. |
ratelimit/errors
Package errors provide data structure for errors.
|
Package errors provide data structure for errors. |
render/standard
* * 模板扩展 * @author swh <swh@admpub.com>
|
* * 模板扩展 * @author swh <swh@admpub.com> |