Documentation ¶
Index ¶
- Constants
- Variables
- func AddTemplFunc(key string, fn interface{}) error
- func CreateSid() string
- func CreateSidTmp() (string, error)
- func DecodeBase64(value []byte) ([]byte, error)
- func EncodeBase64(value []byte) []byte
- func GetNameOfFunction(f interface{}) string
- func GetStatusPrintColor(code int) string
- func HandlerNull(c *WebContext)
- func ParseTime(value string) (time.Time, error)
- func SetDebugLogLevel(l Level)
- func SplitAndTrim(str string, sep string) (string, string, bool)
- func SplitString(str string, sep string) (string, string, bool)
- func StringToBytes(s string) []byte
- func TimeFormat(t time.Time, layout string) (datestring string)
- type AfterExecer
- type BeforeExecer
- type ContextData
- func (c *ContextData) Get(key string) (interface{}, bool)
- func (c *ContextData) GetBool(key string) (bool, error)
- func (s *ContextData) GetFloat64(key string) (float64, error)
- func (s *ContextData) GetInt64(key string) (int64, error)
- func (c *ContextData) GetString(key string) (string, error)
- func (c *ContextData) GetTime(key string) (time.Time, error)
- func (c *ContextData) Set(key string, value interface{})
- type DlogConfig
- type FilterInfo
- type FlashStat
- type FormParam
- func (this *FormParam) GetBool(key string, defaultValue ...bool) ValidBool
- func (this *FormParam) GetFloat(key string, defaultValue ...float64) ValidFloat
- func (this *FormParam) GetInt(key string, defaultValue ...int) ValidInt
- func (this *FormParam) GetInt32(key string, defaultValue ...int32) ValidInt32
- func (this *FormParam) GetInt64(key string, defaultValue ...int64) ValidInt64
- func (this *FormParam) GetString(key string, defaultValue ...string) ValidString
- func (this *FormParam) GetStruct(ptr interface{}) error
- func (this *FormParam) GetTime(key string, format string, defaultValue ...time.Time) ValidTime
- func (this *FormParam) GetValue(key string) (string, bool)
- func (this *FormParam) GetValues(key string) ([]string, bool)
- func (this *FormParam) Init(ctx *WebContext)
- func (this *FormParam) MustBool(key string, defaultValue ...bool) bool
- func (this *FormParam) MustFloat(key string, defaultValue ...float64) float64
- func (this *FormParam) MustInt(key string, defaultValue ...int) int
- func (this *FormParam) MustInt32(key string, defaultValue ...int32) int32
- func (this *FormParam) MustInt64(key string, defaultValue ...int64) int64
- func (this *FormParam) MustString(key string, defaultValue ...string) string
- func (this *FormParam) MustTime(key string, format string, defaultValue ...time.Time) time.Time
- func (this *FormParam) Reset()
- func (this *FormParam) SetValue(key string, val string)
- type FuncGetValues
- type HandlerFunc
- type HandlerType
- type HttpHandler
- type KlogConfig
- type Level
- type LogPrintCB
- type MemcacheConfig
- type MemoryDbConfig
- type ParamItem
- type ParamValue
- type PathParam
- func (this *PathParam) GetBool(key string, defaultValue ...bool) ValidBool
- func (this *PathParam) GetFloat(key string, defaultValue ...float64) ValidFloat
- func (this *PathParam) GetInt(key string, defaultValue ...int) ValidInt
- func (this *PathParam) GetInt32(key string, defaultValue ...int32) ValidInt32
- func (this *PathParam) GetInt64(key string, defaultValue ...int64) ValidInt64
- func (this *PathParam) GetString(key string, defaultValue ...string) ValidString
- func (this *PathParam) GetStruct(ptr interface{}) error
- func (this *PathParam) GetTime(key string, format string, defaultValue ...time.Time) ValidTime
- func (this *PathParam) GetValue(key string) (string, bool)
- func (this *PathParam) GetValues(key string) ([]string, bool)
- func (this *PathParam) Init()
- func (this *PathParam) MustBool(key string, defaultValue ...bool) bool
- func (this *PathParam) MustFloat(key string, defaultValue ...float64) float64
- func (this *PathParam) MustInt(key string, defaultValue ...int) int
- func (this *PathParam) MustInt32(key string, defaultValue ...int32) int32
- func (this *PathParam) MustInt64(key string, defaultValue ...int64) int64
- func (this *PathParam) MustString(key string, defaultValue ...string) string
- func (this *PathParam) MustTime(key string, format string, defaultValue ...time.Time) time.Time
- func (this *PathParam) Reset()
- func (this *PathParam) SetValue(key string, val string)
- type RedisConfig
- type RouteGroup
- func (group *RouteGroup) AddFilter(name string, handler HandlerFunc) bool
- func (group *RouteGroup) AfterExec(handler HandlerFunc)
- func (group *RouteGroup) BeforExec(handler HandlerFunc)
- func (group *RouteGroup) DELETE(pattern string, handler interface{}) *RouteInfo
- func (group *RouteGroup) GET(pattern string, handler interface{}) *RouteInfo
- func (group *RouteGroup) InitRoot(engine *WebEngine)
- func (group *RouteGroup) NewGroup(path string) *RouteGroup
- func (group *RouteGroup) PATCH(pattern string, handler interface{}) *RouteInfo
- func (group *RouteGroup) PATH(pattern string, handler interface{}) *RouteInfo
- func (group *RouteGroup) POST(pattern string, handler interface{}) *RouteInfo
- func (group *RouteGroup) PUT(pattern string, handler interface{}) *RouteInfo
- func (group *RouteGroup) StaticFile(relativePath, filepath string) *RouteInfo
- func (group *RouteGroup) StaticPath(relativePath string, root string) *RouteInfo
- type RouteInfo
- type RouteTree
- type ServerConfig
- type SessionConfig
- type SessionData
- type SessionEngine
- func (this *SessionEngine) CreateSid() (string, error)
- func (this *SessionEngine) Init(store cache.CacheStore)
- func (this *SessionEngine) ReadData(ctx context.Context, sid string) ([]byte, error)
- func (this *SessionEngine) SaveData(ctx context.Context, sid string, data []byte) error
- func (this *SessionEngine) SetCookieName(cookieName string)
- func (this *SessionEngine) SetMaxAge(max_age uint)
- type SessionInfo
- func (this *SessionInfo) Clear()
- func (this *SessionInfo) Delete(key string)
- func (this *SessionInfo) Get(key string) (string, bool)
- func (this *SessionInfo) GetBool(key string) (bool, error)
- func (this *SessionInfo) GetFloat(key string) (float64, error)
- func (this *SessionInfo) GetInt(key string) (int64, error)
- func (this *SessionInfo) GetString(key string) (string, error)
- func (this *SessionInfo) GetStuct(key string, ptr interface{}) error
- func (this *SessionInfo) GetTime(key string) (time.Time, error)
- func (this *SessionInfo) Read() error
- func (this *SessionInfo) Reset()
- func (this *SessionInfo) Save() error
- func (this *SessionInfo) Set(key string, value interface{})
- type ShutdownFunc
- type SimpleLogger
- func (lg *SimpleLogger) Debug(v ...interface{})
- func (lg *SimpleLogger) Debugf(format string, v ...interface{})
- func (lg *SimpleLogger) Error(v ...interface{})
- func (lg *SimpleLogger) Errorf(format string, v ...interface{})
- func (lg *SimpleLogger) Fatal(v ...interface{})
- func (lg *SimpleLogger) Fatalf(format string, v ...interface{})
- func (lg *SimpleLogger) Info(v ...interface{})
- func (lg *SimpleLogger) Infof(format string, v ...interface{})
- func (lg *SimpleLogger) Output(level_str string, msg string) error
- func (lg *SimpleLogger) SetLevel(l Level)
- func (lg *SimpleLogger) Warn(v ...interface{})
- func (lg *SimpleLogger) Warnf(format string, v ...interface{})
- type SkipFlag
- type TagInfo
- type TreeNode
- type TreeNodeX
- type ValidBool
- type ValidFloat
- type ValidInt
- type ValidInt32
- type ValidInt64
- type ValidString
- type ValidTime
- type WebConfig
- func (this *WebConfig) InitCache() error
- func (this *WebConfig) InitDlog() error
- func (this *WebConfig) InitKlog() error
- func (this *WebConfig) InitSession(sess *SessionEngine) error
- func (this *WebConfig) LoadConfig(file_name ...string) error
- func (this *WebConfig) NewCookieStore() (cache.CacheStore, error)
- func (this *WebConfig) NewMemcacheStore() (cache.CacheStore, error)
- func (this *WebConfig) NewMemoryStore() (cache.CacheStore, error)
- func (this *WebConfig) NewRedisStore() (cache.CacheStore, error)
- type WebContext
- func (c *WebContext) Abort(code int)
- func (c *WebContext) Abort401()
- func (c *WebContext) Abort500()
- func (c *WebContext) AbortWithError(code int, err error)
- func (c *WebContext) AbortWithHtml(code int, filenames string, data interface{})
- func (c *WebContext) AbortWithJson(code int, obj interface{})
- func (c *WebContext) AbortWithTemplate(code int, templ *template.Template, data interface{})
- func (c *WebContext) AbortWithText(code int, value string)
- func (c *WebContext) AbortWithTextF(code int, format string, values ...interface{})
- func (c *WebContext) AbortWithXml(code int, obj interface{})
- func (c *WebContext) AcceptWebsocket(opts *gows.AcceptOptions, headers map[string]string) (*gows.WebSocket, error)
- func (c *WebContext) Ended() bool
- func (c *WebContext) GetFile(name string) (*multipart.FileHeader, error)
- func (c *WebContext) GetFiles(key string) ([]*multipart.FileHeader, error)
- func (c *WebContext) Next()
- func (c *WebContext) ReadBody() ([]byte, error)
- func (c *WebContext) ReadJSON(obj interface{}) error
- func (c *WebContext) ReadXML(obj interface{}) error
- func (c *WebContext) Redirect(code int, localurl string)
- func (c *WebContext) SaveToFile(file *multipart.FileHeader, path string) error
- func (c *WebContext) SetCookie(ck *http.Cookie)
- func (c *WebContext) SetHeader(key string, value string)
- func (c *WebContext) Status(code int)
- func (c *WebContext) UseGzip(flag bool, min_size ...int64) *WebContext
- func (c *WebContext) Write(code int, contentType string, data []byte)
- func (c *WebContext) WriteFile(filePath string, fileName ...string)
- func (c *WebContext) WriteHTML(code int, filename string, data interface{})
- func (c *WebContext) WriteHTMLS(code int, filenames []string, data interface{})
- func (c *WebContext) WriteHtmlBytes(code int, data []byte)
- func (c *WebContext) WriteIndentedJSON(code int, obj interface{})
- func (c *WebContext) WriteIndentedXML(code int, obj interface{})
- func (c *WebContext) WriteJSON(code int, obj interface{})
- func (c *WebContext) WriteJSONP(code int, obj interface{})
- func (c *WebContext) WriteLayoutHTML(code int, layout_file string, content_file string, data interface{})
- func (c *WebContext) WriteNoContent(code int, contentType string)
- func (c *WebContext) WriteSecureJSON(code int, obj interface{})
- func (c *WebContext) WriteTemplate(code int, templ *template.Template, data interface{})
- func (c *WebContext) WriteText(code int, data string)
- func (c *WebContext) WriteTextBytes(code int, data []byte)
- func (c *WebContext) WriteTextF(code int, format string, values ...interface{})
- func (c *WebContext) WriteXML(code int, obj interface{})
- type WebEngine
- func (web *WebEngine) BeforRouter(handler HandlerFunc)
- func (web *WebEngine) InitRoute404()
- func (web *WebEngine) Run(addr ...string) (err error)
- func (web *WebEngine) RunHTTP(addr string) error
- func (web *WebEngine) RunTLS(addr string, certFile string, keyFile string) error
- func (web *WebEngine) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (web *WebEngine) SetHandler401(handler HandlerFunc)
- func (web *WebEngine) SetHandler404(handler HandlerFunc)
- func (web *WebEngine) SetHandler500(handler HandlerFunc)
- func (web *WebEngine) SetShutdown(hook ShutdownFunc)
- type WebFlash
- type WebParam
- func (this *WebParam) GetBool(key string, defaultValue ...bool) ValidBool
- func (this *WebParam) GetFloat(key string, defaultValue ...float64) ValidFloat
- func (this *WebParam) GetInt(key string, defaultValue ...int) ValidInt
- func (this *WebParam) GetInt32(key string, defaultValue ...int32) ValidInt32
- func (this *WebParam) GetInt64(key string, defaultValue ...int64) ValidInt64
- func (this *WebParam) GetString(key string, defaultValue ...string) ValidString
- func (this *WebParam) GetStruct(ptr interface{}) error
- func (this *WebParam) GetTime(key string, format string, defaultValue ...time.Time) ValidTime
- func (this *WebParam) GetValue(key string) (string, bool)
- func (this *WebParam) GetValues(key string) ([]string, bool)
- func (this *WebParam) MustBool(key string, defaultValue ...bool) bool
- func (this *WebParam) MustFloat(key string, defaultValue ...float64) float64
- func (this *WebParam) MustInt(key string, defaultValue ...int) int
- func (this *WebParam) MustInt32(key string, defaultValue ...int32) int32
- func (this *WebParam) MustInt64(key string, defaultValue ...int64) int64
- func (this *WebParam) MustString(key string, defaultValue ...string) string
- func (this *WebParam) MustTime(key string, format string, defaultValue ...time.Time) time.Time
- type WebRequest
- func (this *WebRequest) ClientIP() string
- func (this *WebRequest) ContentType() string
- func (this *WebRequest) Cookie(name string) (string, error)
- func (this *WebRequest) GetHeader(key string) string
- func (this *WebRequest) Host() string
- func (this *WebRequest) Method() string
- func (this *WebRequest) Referer() string
- func (this *WebRequest) RemoteIP() string
- func (this *WebRequest) URI() string
- func (this *WebRequest) URL() string
- func (this *WebRequest) UserAgent() string
- type WebResponse
- type WebState
- type WebStatus
- type WebTemplates
Constants ¶
View Source
const ( MethodGet = "GET" MethodPost = "POST" MethodPut = "PUT" MethodPatch = "PATCH" MethodDelete = "DELETE" MethodPath = "PATH" )
View Source
const ContentTypeHTML = "text/html; charset=utf-8"
View Source
const ContentTypeJSON = "application/json; charset=utf-8"
View Source
const ContentTypeText = "text/plain; charset=utf-8"
View Source
const ContentTypeXML = "application/xml; charset=utf-8"
Variables ¶
View Source
var RouteCtxKey string = "RouteContext"
Functions ¶
func AddTemplFunc ¶
func CreateSidTmp ¶ added in v0.4.6
func DecodeBase64 ¶
func EncodeBase64 ¶
func GetNameOfFunction ¶
func GetNameOfFunction(f interface{}) string
func GetStatusPrintColor ¶
func SetDebugLogLevel ¶
func SetDebugLogLevel(l Level)
func StringToBytes ¶
Types ¶
type AfterExecer ¶
type AfterExecer interface {
AfterExec(ctx *WebContext)
}
type BeforeExecer ¶
type BeforeExecer interface {
BeforeExec(ctx *WebContext)
}
type ContextData ¶
type ContextData struct {
// contains filtered or unexported fields
}
func (*ContextData) Get ¶
func (c *ContextData) Get(key string) (interface{}, bool)
func (*ContextData) GetFloat64 ¶
func (s *ContextData) GetFloat64(key string) (float64, error)
func (*ContextData) Set ¶
func (c *ContextData) Set(key string, value interface{})
type DlogConfig ¶
type DlogConfig struct { //日志输出类型配置,0 终端 1 文件 Output int `ini:"output"` //日志输出级别: 0 OFF 1 FATAL 2 ERROR 3 WARN 4 INFO 5 DEBUG Level int `ini:"level;default=5"` //日志文件存储路径,缺省:logs Path string `ini:"path;default=logs"` //是否在日志里面显示源码文件名和行号,默认 true ShowCaller bool `ini:"show_caller;default=true"` //是否将json、xml展开显示 ShowIndent bool `ini:"show_indent;default=true"` }
type FilterInfo ¶
type FilterInfo struct {
// contains filtered or unexported fields
}
type FormParam ¶
type FormParam struct {
// contains filtered or unexported fields
}
func (*FormParam) GetFloat ¶
func (this *FormParam) GetFloat(key string, defaultValue ...float64) ValidFloat
func (*FormParam) GetInt32 ¶
func (this *FormParam) GetInt32(key string, defaultValue ...int32) ValidInt32
func (*FormParam) GetInt64 ¶
func (this *FormParam) GetInt64(key string, defaultValue ...int64) ValidInt64
func (*FormParam) GetString ¶
func (this *FormParam) GetString(key string, defaultValue ...string) ValidString
func (*FormParam) Init ¶
func (this *FormParam) Init(ctx *WebContext)
func (*FormParam) MustString ¶
type FuncGetValues ¶
将urql参数解析到struct 只进行struct的的一层解析
type HandlerType ¶
type HandlerType int
const ( FT_CTL_HANDLER HandlerType = iota FT_CTX_HANDLER FT_RAW_HANDLER )
type HttpHandler ¶
type HttpHandler func(http.ResponseWriter, *http.Request)
type KlogConfig ¶
type LogPrintCB ¶
type MemcacheConfig ¶
type MemcacheConfig struct { //逗号分隔的 memcached 主机列表 Address string `ini:"address"` }
type MemoryDbConfig ¶
type MemoryDbConfig struct { //用于缓存的内存大小,单位:M, 缺省:0(不限制) MaxSize uint64 `ini:"max_size"` }
type ParamValue ¶
type PathParam ¶
type PathParam struct {
// contains filtered or unexported fields
}
func (*PathParam) GetFloat ¶
func (this *PathParam) GetFloat(key string, defaultValue ...float64) ValidFloat
func (*PathParam) GetInt32 ¶
func (this *PathParam) GetInt32(key string, defaultValue ...int32) ValidInt32
func (*PathParam) GetInt64 ¶
func (this *PathParam) GetInt64(key string, defaultValue ...int64) ValidInt64
func (*PathParam) GetString ¶
func (this *PathParam) GetString(key string, defaultValue ...string) ValidString
func (*PathParam) MustString ¶
type RedisConfig ¶
type RouteGroup ¶
type RouteGroup struct {
// contains filtered or unexported fields
}
func (*RouteGroup) AddFilter ¶
func (group *RouteGroup) AddFilter(name string, handler HandlerFunc) bool
func (*RouteGroup) AfterExec ¶
func (group *RouteGroup) AfterExec(handler HandlerFunc)
func (*RouteGroup) BeforExec ¶
func (group *RouteGroup) BeforExec(handler HandlerFunc)
func (*RouteGroup) DELETE ¶
func (group *RouteGroup) DELETE(pattern string, handler interface{}) *RouteInfo
func (*RouteGroup) GET ¶
func (group *RouteGroup) GET(pattern string, handler interface{}) *RouteInfo
func (*RouteGroup) InitRoot ¶
func (group *RouteGroup) InitRoot(engine *WebEngine)
func (*RouteGroup) NewGroup ¶
func (group *RouteGroup) NewGroup(path string) *RouteGroup
func (*RouteGroup) PATCH ¶
func (group *RouteGroup) PATCH(pattern string, handler interface{}) *RouteInfo
func (*RouteGroup) PATH ¶
func (group *RouteGroup) PATH(pattern string, handler interface{}) *RouteInfo
func (*RouteGroup) POST ¶
func (group *RouteGroup) POST(pattern string, handler interface{}) *RouteInfo
func (*RouteGroup) PUT ¶
func (group *RouteGroup) PUT(pattern string, handler interface{}) *RouteInfo
func (*RouteGroup) StaticFile ¶
func (group *RouteGroup) StaticFile(relativePath, filepath string) *RouteInfo
func (*RouteGroup) StaticPath ¶
func (group *RouteGroup) StaticPath(relativePath string, root string) *RouteInfo
type RouteInfo ¶
type RouteInfo struct {
// contains filtered or unexported fields
}
func (*RouteInfo) AfterExec ¶
func (r *RouteInfo) AfterExec(handler HandlerFunc) *RouteInfo
func (*RouteInfo) BeforExec ¶
func (r *RouteInfo) BeforExec(handler HandlerFunc) *RouteInfo
func (*RouteInfo) GetHandlerName ¶
func (*RouteInfo) SkipAfterHook ¶ added in v0.4.6
func (r *RouteInfo) SkipAfterHook()
func (*RouteInfo) SkipBeforHook ¶ added in v0.4.6
func (r *RouteInfo) SkipBeforHook()
type ServerConfig ¶
type ServerConfig struct { //是否启用 HTTPS,默认是false UseHttps bool `ini:"use_https"` //Http监听地址,默认为空 HttpAddr string `ini:"http_addr"` //Http监听端口,默认为 8080 HttpPort uint `ini:"http_port;default=8080"` //Https监听地址,默认为空 HttpsAddr string `ini:"https_addr"` //Https监听端口,默认为 10443 HttpsPort uint `ini:"https_port;default=10443"` //HTTPS证书路径 HttpsCertFile string `ini:"cert_file"` //HTTPS证书 keyfile 的路径 HttpsKeyFile string `ini:"key_file"` //设置 HTTP 的超时时间 ReadTimeout time.Duration `ini:"read_timeout"` //设置 HTTP 的超时时间 WriteTimeout time.Duration `ini:"write_timeout"` //POST请求的默认内存缓存大小,单位:M MaxBody int64 `ini:"max_body"` //是否开启 gzip,输出的内容会进行 gzip,根据Accept-Encoding来判断 EnableGzip bool `ini:"gzip_on"` //压缩长度阈值,只有超过gzip_size的会被压缩返回 GzipSize int64 `ini:"gzip_size"` }
type SessionConfig ¶
type SessionConfig struct { //缓是否开启session, 默认为 false SessionOn bool `ini:"session_on"` //session类型:cookie、cache SessionStore string `ini:"session_store;default=cookie"` //客户端的cookie的名称前缀 CookieName string `ini:"cookie_name;default=wego"` //保存session数据的cookie域名, 默认空 Domain string `ini:"domain"` //session 过期时间,单位:秒,默认值是3600 LifeTime uint `ini:"life_time;default=3600"` //设置cookie的SameSite属性 SameSite http.SameSite `ini:"samesite"` //session数据的hash字符串,若session的存储类型为cookie,则必须提供 HashKey string `ini:"hash_key"` }
type SessionData ¶
type SessionEngine ¶
type SessionEngine struct {
// contains filtered or unexported fields
}
func (*SessionEngine) CreateSid ¶
func (this *SessionEngine) CreateSid() (string, error)
func (*SessionEngine) Init ¶
func (this *SessionEngine) Init(store cache.CacheStore)
func (*SessionEngine) SetCookieName ¶
func (this *SessionEngine) SetCookieName(cookieName string)
func (*SessionEngine) SetMaxAge ¶
func (this *SessionEngine) SetMaxAge(max_age uint)
type SessionInfo ¶
type SessionInfo struct { Sid string Data SessionData Edit bool // contains filtered or unexported fields }
func (*SessionInfo) Clear ¶
func (this *SessionInfo) Clear()
func (*SessionInfo) Delete ¶
func (this *SessionInfo) Delete(key string)
func (*SessionInfo) GetStuct ¶
func (this *SessionInfo) GetStuct(key string, ptr interface{}) error
func (*SessionInfo) Read ¶
func (this *SessionInfo) Read() error
func (*SessionInfo) Reset ¶
func (this *SessionInfo) Reset()
func (*SessionInfo) Save ¶
func (this *SessionInfo) Save() error
func (*SessionInfo) Set ¶
func (this *SessionInfo) Set(key string, value interface{})
type ShutdownFunc ¶
type ShutdownFunc func()
type SimpleLogger ¶
type SimpleLogger struct {
// contains filtered or unexported fields
}
func NewSimpleLogger ¶
func NewSimpleLogger() *SimpleLogger
func (*SimpleLogger) Debug ¶
func (lg *SimpleLogger) Debug(v ...interface{})
func (*SimpleLogger) Debugf ¶
func (lg *SimpleLogger) Debugf(format string, v ...interface{})
func (*SimpleLogger) Error ¶
func (lg *SimpleLogger) Error(v ...interface{})
func (*SimpleLogger) Errorf ¶
func (lg *SimpleLogger) Errorf(format string, v ...interface{})
func (*SimpleLogger) Fatal ¶
func (lg *SimpleLogger) Fatal(v ...interface{})
func (*SimpleLogger) Fatalf ¶
func (lg *SimpleLogger) Fatalf(format string, v ...interface{})
func (*SimpleLogger) Info ¶
func (lg *SimpleLogger) Info(v ...interface{})
func (*SimpleLogger) Infof ¶
func (lg *SimpleLogger) Infof(format string, v ...interface{})
func (*SimpleLogger) SetLevel ¶
func (lg *SimpleLogger) SetLevel(l Level)
func (*SimpleLogger) Warn ¶
func (lg *SimpleLogger) Warn(v ...interface{})
func (*SimpleLogger) Warnf ¶
func (lg *SimpleLogger) Warnf(format string, v ...interface{})
type TreeNode ¶
type TreeNode struct {
// contains filtered or unexported fields
}
type TreeNodeX ¶
type TreeNodeX struct {
// contains filtered or unexported fields
}
type ValidFloat ¶
type ValidInt32 ¶
type ValidInt64 ¶
type ValidString ¶
type WebConfig ¶
type WebConfig struct { wini.ConfigData //应用名称 AppName string `ini:"app_name"` //服务器名称 ServerName string `ini:"server_name"` //缓是否开启缓存 CacheOn bool `ini:"cache_on"` //cache类型:redis、memcache、memory CacheStore string `ini:"cache_store;default=memory"` //是否显示请求日志,默认为 true ShowUrlLog bool `ini:"show_url_log;default=true"` //是否显示请求日志,默认为 true ShowSqlLog bool `ini:"show_sql_log;default=true"` //设置调试日志级别:0 OFF 1 FATAL 2 ERROR 3 WARN 4 INFO 5 DEBUG ShowDebugLog int `ini:"show_debug_log"` //防JSON劫持的前缀字符串 JsonPrefix string `ini:"json_prefix"` //获取client ip的header IPHeader string `ini:"ip_header"` //Web服务配置 ServerParam ServerConfig `ini:"server"` //Session配置 SessionParam SessionConfig `ini:"session"` //内存缓存配置 MemoryDbParam MemoryDbConfig `ini:"memory"` //Redis缓存配置 RedisParam RedisConfig `ini:"redis"` //Memcache缓存配置 MemcacheParam MemcacheConfig `ini:"memcache"` //日志模块配置 DlogParam DlogConfig `ini:"dlog"` //统计日志配置 KlogParam KlogConfig `ini:"klog"` }
func (*WebConfig) InitSession ¶
func (this *WebConfig) InitSession(sess *SessionEngine) error
通过配置参数初始化Session
func (*WebConfig) NewCookieStore ¶
func (this *WebConfig) NewCookieStore() (cache.CacheStore, error)
通过配置参数初创建CookieStore
func (*WebConfig) NewMemcacheStore ¶
func (this *WebConfig) NewMemcacheStore() (cache.CacheStore, error)
通过配置参数初创建MemcacheStore
func (*WebConfig) NewMemoryStore ¶
func (this *WebConfig) NewMemoryStore() (cache.CacheStore, error)
通过配置参数初创建MemoryStore
func (*WebConfig) NewRedisStore ¶
func (this *WebConfig) NewRedisStore() (cache.CacheStore, error)
通过配置参数初创建RedisStore
type WebContext ¶
type WebContext struct { Config *WebConfig Input WebRequest Output WebResponse Route *RouteInfo Path string Param WebParam RouteParam PathParam QueryParam FormParam FormParam FormParam Data ContextData Session SessionInfo Start time.Time // contains filtered or unexported fields }
func GetWebContext ¶
func GetWebContext(r *http.Request) *WebContext
func (*WebContext) Abort ¶
func (c *WebContext) Abort(code int)
func (*WebContext) Abort401 ¶
func (c *WebContext) Abort401()
func (*WebContext) Abort500 ¶
func (c *WebContext) Abort500()
func (*WebContext) AbortWithError ¶
func (c *WebContext) AbortWithError(code int, err error)
func (*WebContext) AbortWithHtml ¶
func (c *WebContext) AbortWithHtml(code int, filenames string, data interface{})
func (*WebContext) AbortWithJson ¶
func (c *WebContext) AbortWithJson(code int, obj interface{})
func (*WebContext) AbortWithTemplate ¶
func (c *WebContext) AbortWithTemplate(code int, templ *template.Template, data interface{})
func (*WebContext) AbortWithText ¶
func (c *WebContext) AbortWithText(code int, value string)
func (*WebContext) AbortWithTextF ¶
func (c *WebContext) AbortWithTextF(code int, format string, values ...interface{})
func (*WebContext) AbortWithXml ¶
func (c *WebContext) AbortWithXml(code int, obj interface{})
func (*WebContext) AcceptWebsocket ¶ added in v1.1.3
func (c *WebContext) AcceptWebsocket(opts *gows.AcceptOptions, headers map[string]string) (*gows.WebSocket, error)
websocket握手
func (*WebContext) Ended ¶
func (c *WebContext) Ended() bool
func (*WebContext) GetFile ¶
func (c *WebContext) GetFile(name string) (*multipart.FileHeader, error)
func (*WebContext) GetFiles ¶
func (c *WebContext) GetFiles(key string) ([]*multipart.FileHeader, error)
func (*WebContext) Next ¶
func (c *WebContext) Next()
func (*WebContext) ReadBody ¶
func (c *WebContext) ReadBody() ([]byte, error)
func (*WebContext) ReadJSON ¶
func (c *WebContext) ReadJSON(obj interface{}) error
func (*WebContext) ReadXML ¶
func (c *WebContext) ReadXML(obj interface{}) error
func (*WebContext) Redirect ¶
func (c *WebContext) Redirect(code int, localurl string)
func (*WebContext) SaveToFile ¶
func (c *WebContext) SaveToFile(file *multipart.FileHeader, path string) error
func (*WebContext) SetCookie ¶
func (c *WebContext) SetCookie(ck *http.Cookie)
Domain:定义Cookie的生效作用域,只有当域名和路径同时满足的时候,浏览器才会将Cookie发送给Server。 Expires:过期时间,绝对时间点。 Max-Age:收到报文后多久的过期时间,单位是秒。设置为0时立刻失效。 HttpOnly:如设为True,JavaScript这些脚本无法访问,即有效减少 XSS 攻击 Secure:如设置secure为true,浏览器只会在HTTPS和SSL等安全协议中传输Cookie。 SameSite:可以防范 CSRF 攻击。
SameSite=None:无论是否跨站都会发送 Cookie, SameSite=Lax:允许部分第三方请求携带 Cookie, SameSite=Strict:仅允许同站请求携带 Cookie,即当前网页 URL 与请求目标 URL 完全一致
func (*WebContext) SetHeader ¶
func (c *WebContext) SetHeader(key string, value string)
func (*WebContext) Status ¶
func (c *WebContext) Status(code int)
func (*WebContext) UseGzip ¶
func (c *WebContext) UseGzip(flag bool, min_size ...int64) *WebContext
func (*WebContext) WriteFile ¶
func (c *WebContext) WriteFile(filePath string, fileName ...string)
func (*WebContext) WriteHTML ¶
func (c *WebContext) WriteHTML(code int, filename string, data interface{})
func (*WebContext) WriteHTMLS ¶
func (c *WebContext) WriteHTMLS(code int, filenames []string, data interface{})
func (*WebContext) WriteHtmlBytes ¶
func (c *WebContext) WriteHtmlBytes(code int, data []byte)
func (*WebContext) WriteIndentedJSON ¶
func (c *WebContext) WriteIndentedJSON(code int, obj interface{})
美化JSON的输出,可以使用json.MarshalIndent方法对obj进行编码
func (*WebContext) WriteIndentedXML ¶
func (c *WebContext) WriteIndentedXML(code int, obj interface{})
func (*WebContext) WriteJSON ¶
func (c *WebContext) WriteJSON(code int, obj interface{})
func (*WebContext) WriteJSONP ¶
func (c *WebContext) WriteJSONP(code int, obj interface{})
输出JSONP,使用callback参数名作为接收回调函数的名称
func (*WebContext) WriteLayoutHTML ¶
func (c *WebContext) WriteLayoutHTML(code int, layout_file string, content_file string, data interface{})
func (*WebContext) WriteNoContent ¶
func (c *WebContext) WriteNoContent(code int, contentType string)
func (*WebContext) WriteSecureJSON ¶
func (c *WebContext) WriteSecureJSON(code int, obj interface{})
防JSON劫持缺省的前缀是while(1);
func (*WebContext) WriteTemplate ¶
func (c *WebContext) WriteTemplate(code int, templ *template.Template, data interface{})
func (*WebContext) WriteText ¶
func (c *WebContext) WriteText(code int, data string)
func (*WebContext) WriteTextBytes ¶
func (c *WebContext) WriteTextBytes(code int, data []byte)
func (*WebContext) WriteTextF ¶
func (c *WebContext) WriteTextF(code int, format string, values ...interface{})
func (*WebContext) WriteXML ¶
func (c *WebContext) WriteXML(code int, obj interface{})
type WebEngine ¶
type WebEngine struct { RouteGroup //路由树对象 Route RouteTree //html tepmplates缓存 Templates WebTemplates //session引擎 Session SessionEngine //配置参数 Config WebConfig //获取Ip的header IPHeaders []string // contains filtered or unexported fields }
func InitWebWithFile ¶ added in v1.0.4
func (*WebEngine) BeforRouter ¶
func (web *WebEngine) BeforRouter(handler HandlerFunc)
func (*WebEngine) InitRoute404 ¶
func (web *WebEngine) InitRoute404()
func (*WebEngine) ServeHTTP ¶
func (web *WebEngine) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*WebEngine) SetHandler401 ¶
func (web *WebEngine) SetHandler401(handler HandlerFunc)
func (*WebEngine) SetHandler404 ¶
func (web *WebEngine) SetHandler404(handler HandlerFunc)
func (*WebEngine) SetHandler500 ¶
func (web *WebEngine) SetHandler500(handler HandlerFunc)
func (*WebEngine) SetShutdown ¶
func (web *WebEngine) SetShutdown(hook ShutdownFunc)
type WebFlash ¶
func ReadFlash ¶
func ReadFlash(ctx *WebContext) *WebFlash
func (*WebFlash) ReadData ¶
func (this *WebFlash) ReadData(ctx *WebContext) error
func (*WebFlash) SaveData ¶
func (this *WebFlash) SaveData(ctx *WebContext) error
func (*WebFlash) SaveErrorData ¶
func (this *WebFlash) SaveErrorData(ctx *WebContext) error
func (*WebFlash) SaveSuccessData ¶
func (this *WebFlash) SaveSuccessData(ctx *WebContext) error
type WebParam ¶
type WebParam struct {
// contains filtered or unexported fields
}
func (*WebParam) GetFloat ¶
func (this *WebParam) GetFloat(key string, defaultValue ...float64) ValidFloat
func (*WebParam) GetInt32 ¶
func (this *WebParam) GetInt32(key string, defaultValue ...int32) ValidInt32
func (*WebParam) GetInt64 ¶
func (this *WebParam) GetInt64(key string, defaultValue ...int64) ValidInt64
func (*WebParam) GetString ¶
func (this *WebParam) GetString(key string, defaultValue ...string) ValidString
func (*WebParam) MustString ¶
type WebRequest ¶
func (*WebRequest) ClientIP ¶
func (this *WebRequest) ClientIP() string
func (*WebRequest) ContentType ¶
func (this *WebRequest) ContentType() string
func (*WebRequest) GetHeader ¶
func (this *WebRequest) GetHeader(key string) string
func (*WebRequest) Host ¶
func (this *WebRequest) Host() string
func (*WebRequest) Method ¶
func (this *WebRequest) Method() string
func (*WebRequest) Referer ¶
func (this *WebRequest) Referer() string
func (*WebRequest) RemoteIP ¶
func (this *WebRequest) RemoteIP() string
func (*WebRequest) URI ¶
func (this *WebRequest) URI() string
func (*WebRequest) URL ¶
func (this *WebRequest) URL() string
func (*WebRequest) UserAgent ¶
func (this *WebRequest) UserAgent() string
type WebResponse ¶
type WebResponse struct { http.ResponseWriter StatusCode int // contains filtered or unexported fields }
func (*WebResponse) Flush ¶
func (w *WebResponse) Flush() error
func (*WebResponse) GetStatus ¶
func (w *WebResponse) GetStatus() int
func (*WebResponse) SetStatus ¶
func (w *WebResponse) SetStatus(code int)
func (*WebResponse) WriteHeader ¶
func (w *WebResponse) WriteHeader(code int)
func (*WebResponse) WroteHeader ¶
func (w *WebResponse) WroteHeader() bool
type WebTemplates ¶
type WebTemplates struct {
// contains filtered or unexported fields
}
func (*WebTemplates) Init ¶
func (this *WebTemplates) Init()
func (*WebTemplates) SetDelim ¶
func (this *WebTemplates) SetDelim(left, right string)
Source Files ¶
- context_data.go
- form_decode.go
- form_param.go
- form_param_web.go
- handler_type.go
- log_print.go
- logger_in.go
- max_reader.go
- media_type.go
- mock_writer.go
- param_type.go
- path_fix.go
- path_param.go
- recovery.go
- route_info.go
- route_node.go
- route_nodex.go
- route_tree.go
- session.go
- session_engine.go
- session_id.go
- struct_tag.go
- templ_func.go
- web_config.go
- web_context.go
- web_engine.go
- web_flash.go
- web_group.go
- web_reponse.go
- web_request.go
- web_templates.go
Directories ¶
Path | Synopsis |
---|---|
mod/memcache
Package memcache provides a client for the memcached cache server.
|
Package memcache provides a client for the memcached cache server. |
mod/redis
Package redis is a client for the Redis database.
|
Package redis is a client for the Redis database. |
Click to show internal directories.
Click to hide internal directories.