Documentation ¶
Index ¶
- Variables
- type App
- func (a *App) AfterFilter(pattern string, filterHandler FilterHandler) *App
- func (a *App) AfterInterceptor(pattern string, interceptorHandler InterceptorHandler) *App
- func (a *App) Banner(banner bool) *App
- func (a *App) BeforeFilter(pattern string, filterHandler FilterHandler) *App
- func (a *App) BeforeInterceptor(pattern string, interceptorHandler InterceptorHandler) *App
- func (a *App) ClearCaches()
- func (a *App) DefaultHandler(handler Handler) *App
- func (a *App) Delete(pattern string, handler Handler, fields ...*Field) *App
- func (a *App) FaviconIco() *App
- func (a *App) Get(pattern string, handler Handler, fields ...*Field) *App
- func (a *App) GetAllCaches() map[string]interface{}
- func (a *App) GetCache(key string) interface{}
- func (a *App) GetContextPath() string
- func (a *App) GetSessionEnable() bool
- func (a *App) GetStaticCache() bool
- func (a *App) GetStaticEnable() bool
- func (a *App) GetStaticPattern() string
- func (a *App) GetStaticPrefix() string
- func (a *App) GetTemplateDelimLeft() string
- func (a *App) GetTemplateDelimRight() string
- func (a *App) GetTemplateEnable() bool
- func (a *App) GetTemplateFuncs() template.FuncMap
- func (a *App) GetValidateErrCode() int
- func (a *App) GetViewCache() bool
- func (a *App) GetViewEnable() bool
- func (a *App) GetViewPrefix() string
- func (a *App) GetViewSuffix() string
- func (a *App) GetWebRoot() string
- func (a *App) LogFatal(message string, args ...interface{})
- func (a *App) LogInfo(message string, args ...interface{})
- func (a *App) LogWarn(message string, args ...interface{})
- func (a *App) Patch(pattern string, handler Handler, fields ...*Field) *App
- func (a *App) Post(pattern string, handler Handler, fields ...*Field) *App
- func (a *App) PreflightedHandler(handler Handler) *App
- func (a *App) Put(pattern string, handler Handler, fields ...*Field) *App
- func (a *App) RegisterStaticRes(fileExt, contentType string) *App
- func (a *App) RemoveCache(key string)
- func (a *App) Req(pattern string, handler Handler, fields ...*Field) *App
- func (a *App) RequestNotSupportedHandler(handler Handler) *App
- func (a *App) Run()
- func (a *App) RunAs(host string, port int)
- func (a *App) SessionEnable(sessionEnable bool) *App
- func (a *App) SessionProvider(sessionProvider SessionProvider) *App
- func (a *App) Sessions() map[string]Session
- func (a *App) SetCache(key string, data interface{})
- func (a *App) SetContextPath(contextPath string) *App
- func (a *App) SetSessionEnable(enable bool) *App
- func (a *App) SetStaticCache(cache bool) *App
- func (a *App) SetStaticEnable(enable bool) *App
- func (a *App) SetStaticPattern(pattern string) *App
- func (a *App) SetStaticPrefix(prefix string) *App
- func (a *App) SetTemplateDelimLeft(left string) *App
- func (a *App) SetTemplateDelimRight(right string) *App
- func (a *App) SetTemplateEnable(enable bool) *App
- func (a *App) SetTemplateFuncs(funcMap template.FuncMap) *App
- func (a *App) SetValidateErrCode(code int) *App
- func (a *App) SetViewCache(cache bool) *App
- func (a *App) SetViewEnable(enable bool) *App
- func (a *App) SetViewPrefix(prefix string) *App
- func (a *App) SetViewSuffix(suffix string) *App
- func (a *App) SetWebRoot(webRoot string) *App
- func (a *App) TLS(certFile, keyFile string)
- func (a *App) Use(middlewares ...Middleware) *App
- func (a *App) UseFilter(filterMiddlewares ...FilterMiddleware) *App
- func (a *App) UseFilterWithConfig(fmwConfig FilterMiddlewareConfig, filterMiddleware FilterMiddleware) *App
- func (a *App) UseInterceptor(interceptorMiddlewares ...InterceptorMiddleware) *App
- func (a *App) UseInterceptorWithConfig(imwConfig InterceptorMiddlewareConfig, ...) *App
- func (a *App) UseWithConfig(mwConfig MiddlewareConfig, middleware Middleware) *App
- type Context
- func (c *Context) AddHeader(name, value string) *Context
- func (c *Context) AddViewFuncMap(name string, fn interface{}) *Context
- func (c *Context) Binary(buffer []byte)
- func (c *Context) BinaryWith(buffer []byte, contentType string)
- func (c *Context) ClearCaches()
- func (c *Context) ClearMiddlewareCtx(name string)
- func (c *Context) GetCache(key string) interface{}
- func (c *Context) GetMiddlewareCtx(name string) map[string]interface{}
- func (c *Context) GetMiddlewareData(name, key string) interface{}
- func (c *Context) GetMultipartFile(name string) *MultipartFile
- func (c *Context) GetMultipartFiles(name string) []*MultipartFile
- func (c *Context) GetParameter(name string) string
- func (c *Context) GetParameterWithDefault(name, defaultValue string) string
- func (c *Context) GetParameters(name string) []string
- func (c *Context) GetParametersWithDefault(name string, defaultValue []string) []string
- func (c *Context) Image(buffer []byte)
- func (c *Context) JSON(data interface{})
- func (c *Context) ParseMultipart(maxMemory int64) error
- func (c *Context) RemoveCache(key string)
- func (c *Context) RemoveMiddlewareData(name, key string)
- func (c *Context) SetCache(key string, data interface{})
- func (c *Context) SetDone(done bool) *Context
- func (c *Context) SetHeader(name, value string) *Context
- func (c *Context) SetMiddlewareData(name, key string, val interface{})
- func (c *Context) SetViewFuncMap(funcMap template.FuncMap) *Context
- func (c *Context) Text(text string)
- func (c *Context) View(name string)
- func (c *Context) ViewWithData(name string, data map[string]interface{})
- type Field
- func (field *Field) Concat(concat bool) *Field
- func (field *Field) ConcatRune(concatRune rune) *Field
- func (field *Field) DefaultVal(defaultVal string) *Field
- func (field *Field) Enums(enums ...string) *Field
- func (field *Field) Fixed(fixed string) *Field
- func (field *Field) Length(length int) *Field
- func (field *Field) Max(max int) *Field
- func (field *Field) MaxLength(maxLength int) *Field
- func (field *Field) Min(min int) *Field
- func (field *Field) MinLength(minLength int) *Field
- func (field *Field) Name(name string) *Field
- func (field *Field) Preset(preset bool) *Field
- func (field *Field) Regex(regex string) *Field
- func (field *Field) Split(split bool) *Field
- func (field *Field) SplitRune(splitRune rune) *Field
- func (field *Field) Validate(validate bool) *Field
- type FilterContext
- func (c *FilterContext) ClearCaches()
- func (c *FilterContext) ClearMiddlewareCtx(name string)
- func (c *FilterContext) GetCache(key string) interface{}
- func (c *FilterContext) GetMiddlewareCtx(name string) map[string]interface{}
- func (c *FilterContext) GetMiddlewareData(name, key string) interface{}
- func (c *FilterContext) RemoveCache(key string)
- func (c *FilterContext) RemoveMiddlewareData(name, key string)
- func (c *FilterContext) SetCache(key string, data interface{})
- func (c *FilterContext) SetMiddlewareData(name, key string, val interface{})
- type FilterHandler
- type FilterMiddleware
- type FilterMiddlewareConfig
- type Handler
- type InterceptorHandler
- type InterceptorMiddleware
- type InterceptorMiddlewareConfig
- type Middleware
- type MiddlewareConfig
- type MultipartFile
- type Response
- type Session
- type SessionConfig
- type SessionCreatedListener
- type SessionDestoryedListener
- type SessionProvider
- type SessionRefreshedListener
- type StaticHandler
Constants ¶
This section is empty.
Variables ¶
var Logger = &logger{}
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { SessionConfig *SessionConfig //Session Config // contains filtered or unexported fields }
Define app struct
func (*App) AfterFilter ¶
func (a *App) AfterFilter(pattern string, filterHandler FilterHandler) *App
Route after filter
func (*App) AfterInterceptor ¶
func (a *App) AfterInterceptor(pattern string, interceptorHandler InterceptorHandler) *App
Route after interceptor
func (*App) BeforeFilter ¶
func (a *App) BeforeFilter(pattern string, filterHandler FilterHandler) *App
Route before filter
func (*App) BeforeInterceptor ¶
func (a *App) BeforeInterceptor(pattern string, interceptorHandler InterceptorHandler) *App
Route before interceptor
func (*App) DefaultHandler ¶
Config default handler
func (*App) GetTemplateDelimLeft ¶
Get Template delims left
func (*App) GetTemplateDelimRight ¶
Get Template delims right
func (*App) PreflightedHandler ¶
Config preflighted handler
func (*App) RegisterStaticRes ¶
Register a static res
func (*App) RequestNotSupportedHandler ¶
Config request not supported handler
func (*App) SessionProvider ¶
func (a *App) SessionProvider(sessionProvider SessionProvider) *App
Get app session provider
func (*App) SetStaticPattern ¶
Set static pattern
func (*App) SetTemplateDelimLeft ¶
Set Template delims left
func (*App) SetTemplateDelimRight ¶
Set Template delims right
func (*App) SetTemplateEnable ¶
Set Template enable
func (*App) SetTemplateFuncs ¶
Set Template funcs
func (*App) SetValidateErrCode ¶
Set validate err code
func (*App) UseFilter ¶
func (a *App) UseFilter(filterMiddlewares ...FilterMiddleware) *App
Using filter middlewares
func (*App) UseFilterWithConfig ¶
func (a *App) UseFilterWithConfig(fmwConfig FilterMiddlewareConfig, filterMiddleware FilterMiddleware) *App
Using filter middlewares with config
func (*App) UseInterceptor ¶
func (a *App) UseInterceptor(interceptorMiddlewares ...InterceptorMiddleware) *App
Using interceptor middlewares
func (*App) UseInterceptorWithConfig ¶
func (a *App) UseInterceptorWithConfig(imwConfig InterceptorMiddlewareConfig, interceptorMiddleware InterceptorMiddleware) *App
Using interceptor middlewares with config
func (*App) UseWithConfig ¶
func (a *App) UseWithConfig(mwConfig MiddlewareConfig, middleware Middleware) *App
Using middlewares with config
type Context ¶
type Context struct { Request *http.Request //request RequestURI string //request uri ParsedRequestURI string //parsed request uri RequestMethod string //request method RequestHeader http.Header //request header ResponseWriter http.ResponseWriter //Response writer ResponseHeader *http.Header //Response header Multipart map[string][]*MultipartFile //multipart map Parameters map[string][]string //map[string][]string MultipartParsed bool //multipart parsed ? Response *Response //Response Cookies map[string]*http.Cookie //cookies SessionId string //session id Session Session //session // contains filtered or unexported fields }
Define Context struct
func (*Context) AddViewFuncMap ¶
Add view funcMap
func (*Context) BinaryWith ¶
Response binary to client with ContentType
func (*Context) ClearMiddlewareCtx ¶
Clear middleware c
func (*Context) GetMiddlewareCtx ¶
Get middleware c
func (*Context) GetMiddlewareData ¶
Get middleware data
func (*Context) GetMultipartFile ¶
func (c *Context) GetMultipartFile(name string) *MultipartFile
Get multipart file
func (*Context) GetMultipartFiles ¶
func (c *Context) GetMultipartFiles(name string) []*MultipartFile
Get request parameter
func (*Context) GetParameter ¶
Get request parameter
func (*Context) GetParameterWithDefault ¶
Get request parameter with default
func (*Context) GetParameters ¶
Get request parameters
func (*Context) GetParametersWithDefault ¶
Get request parameters with default
func (*Context) ParseMultipart ¶
Parse Multipart
func (*Context) RemoveMiddlewareData ¶
Remove middleware data
func (*Context) SetMiddlewareData ¶
Set middleware data
func (*Context) SetViewFuncMap ¶
Set view funcMap
func (*Context) ViewWithData ¶
Response view to client with data
type FilterContext ¶
type FilterContext struct { RequestURI string ParsedRequestURI string RequestMethod string RequestHeader http.Header ResponseHeader *http.Header Parameters map[string][]string // contains filtered or unexported fields }
Define FilterContext struct
func (*FilterContext) ClearMiddlewareCtx ¶
func (c *FilterContext) ClearMiddlewareCtx(name string)
Clear middleware c
func (*FilterContext) GetCache ¶
func (c *FilterContext) GetCache(key string) interface{}
Get app cache
func (*FilterContext) GetMiddlewareCtx ¶
func (c *FilterContext) GetMiddlewareCtx(name string) map[string]interface{}
Get middleware ctx
func (*FilterContext) GetMiddlewareData ¶
func (c *FilterContext) GetMiddlewareData(name, key string) interface{}
Get middleware data
func (*FilterContext) RemoveCache ¶
func (c *FilterContext) RemoveCache(key string)
Remove app cache
func (*FilterContext) RemoveMiddlewareData ¶
func (c *FilterContext) RemoveMiddlewareData(name, key string)
Remove middleware data
func (*FilterContext) SetCache ¶
func (c *FilterContext) SetCache(key string, data interface{})
Set app cache
func (*FilterContext) SetMiddlewareData ¶
func (c *FilterContext) SetMiddlewareData(name, key string, val interface{})
Set middleware data
type FilterMiddleware ¶
type FilterMiddleware interface { //Set FilterMiddleware name Name() string //Set FilterMiddleware type Type() string //Set FilterMiddleware pattern Pattern() string //Process FilterMiddleware Process() FilterHandler }
Define Filter Middleware interface
type FilterMiddlewareConfig ¶
Define FilterMiddlewareConfig struct
type InterceptorMiddleware ¶
type InterceptorMiddleware interface { //Set InterceptorMiddleware name Name() string //Set InterceptorMiddleware type Type() string //Set InterceptorMiddleware pattern Pattern() string //Process InterceptorMiddleware Process() InterceptorHandler }
Define Interceptor Middleware interface
type InterceptorMiddlewareConfig ¶
Define InterceptorMiddlewareConfig struct
type Middleware ¶
type Middleware interface { //Set Middleware name Name() string //Set Middleware method Method() string //Set Middleware pattern Pattern() string //Process Middleware Process() Handler //Set Middleware fields Fields() []*Field }
Define Middleware interface
type MiddlewareConfig ¶
Define MiddlewareConfig struct
type MultipartFile ¶
type MultipartFile struct {
// contains filtered or unexported fields
}
Define MultipartFile struct
func (*MultipartFile) ContentType ¶
func (file *MultipartFile) ContentType() string
Get multipart file content type
func (*MultipartFile) Copy ¶
func (file *MultipartFile) Copy(distName string) error
Copy file to dist name
func (*MultipartFile) Filename ¶
func (file *MultipartFile) Filename() string
Get multipart file name
func (*MultipartFile) Header ¶
func (file *MultipartFile) Header(name string) string
Get multipart header
func (*MultipartFile) Headers ¶
func (file *MultipartFile) Headers() map[string][]string
Get multipart headers
func (*MultipartFile) Size ¶
func (file *MultipartFile) Size() int64
Get multipart file size in byte
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Define Response struct
func (*Response) GetContentType ¶
Get content type
func (*Response) SetContentType ¶
Set content type
type Session ¶
type Session interface { Id() string //Get session Id SetExpiresTime(lifeTime time.Duration) //Set expires time Get(name string) interface{} //Get data GetAll() map[string]interface{} //Get all data Set(name string, val interface{}) //Set data SetAll(data map[string]interface{}, flush bool) //Set all data Del(name string) //Del by name Clear() //Clear all data }
Define Session interface
type SessionConfig ¶
type SessionConfig struct { Timeout time.Duration //session idle timeout CreatedListener sessionListener //SessionCreatedListener DestoryedListener sessionListener //SessionDestoryedListener RefreshedListener sessionListener //SessionRefreshedListener }
Define SessionConfig struct
type SessionCreatedListener ¶
type SessionCreatedListener sessionListener
call when the session be created
type SessionDestoryedListener ¶
type SessionDestoryedListener sessionListener
call when the session be destoryed
type SessionProvider ¶
type SessionProvider interface { Exists(id string) bool //Get session is exists GetId(r *http.Request) string //Get SessionId from client Del(id string) //Del Session from provider Get(id string) Session //Get Session from provider GetAll() map[string]Session //Get All Session from provider New(config *SessionConfig) Session //Get new Session from provider Clear() //Clear all sessions Refresh(session Session, config *SessionConfig) //Refresh handler from provider }
Define SessionProvider interface
type SessionRefreshedListener ¶
type SessionRefreshedListener sessionListener
call when the session be refreshed
type StaticHandler ¶
Define static handler