Documentation ¶
Index ¶
- Constants
- Variables
- func Configure(obj interface{}, config map[string]interface{})
- func ConstructAndInit(obj interface{}, config map[string]interface{}, params ...interface{})
- func CreateObject(class interface{}, params ...interface{}) interface{}
- func Decode(data interface{}, ptr interface{})
- func Encode(data interface{}) []byte
- func GetAlias(alias string) string
- func LevelToString(level int) string
- func Run()
- func SetAlias(alias, path string)
- func StringToLevel(level string) int
- func TimeRun() time.Duration
- type Application
- func (app *Application) Construct()
- func (app *Application) Get(id string) interface{}
- func (app *Application) GetBasePath() string
- func (app *Application) GetConfig() *Config
- func (app *Application) GetContainer() *Container
- func (app *Application) GetEnv() string
- func (app *Application) GetI18n() *I18n
- func (app *Application) GetLog() *Log
- func (app *Application) GetMode() int
- func (app *Application) GetName() string
- func (app *Application) GetPublicPath() string
- func (app *Application) GetRouter() *Router
- func (app *Application) GetRuntimePath() string
- func (app *Application) GetServer() *Server
- func (app *Application) GetStatus() *Status
- func (app *Application) GetStopBefore() *StopBefore
- func (app *Application) GetView() *View
- func (app *Application) GetViewPath() string
- func (app *Application) Init()
- type BoolValidator
- type Config
- func (c *Config) AddParser(ext string, parser IConfigParser)
- func (c *Config) AddPath(path string)
- func (c *Config) Construct()
- func (c *Config) Get(key string) interface{}
- func (c *Config) GetBool(key string, dft bool) bool
- func (c *Config) GetFloat(key string, dft float64) float64
- func (c *Config) GetInt(key string, dft int) int
- func (c *Config) GetSliceBool(key string) []bool
- func (c *Config) GetSliceFloat(key string) []float64
- func (c *Config) GetSliceInt(key string) []int
- func (c *Config) GetSliceString(key string) []string
- func (c *Config) GetString(key string, dft string) string
- func (c *Config) Load(name string)
- func (c *Config) Set(key string, val interface{})
- type ConsoleTarget
- type Container
- func (c *Container) Bind(i interface{})
- func (c *Container) Construct()
- func (c *Container) Get(name string, config map[string]interface{}, params ...interface{}) reflect.Value
- func (c *Container) GetInfo(name string) interface{}
- func (c *Container) GetType(name string) reflect.Type
- func (c *Container) Has(name string) bool
- func (c *Container) Put(name string, rv reflect.Value)
- func (c *Container) SetEnablePool(enable bool)
- type Context
- func (c *Context) Abort()
- func (c *Context) Copy() *Context
- func (c *Context) End(status int, data []byte)
- func (c *Context) GetActionId() string
- func (c *Context) GetClientIp() string
- func (c *Context) GetControllerId() string
- func (c *Context) GetCookie(name, dft string) string
- func (c *Context) GetCookieAll() map[string]string
- func (c *Context) GetElapseMs() int
- func (c *Context) GetHeader(name, dft string) string
- func (c *Context) GetHeaderAll() map[string]string
- func (c *Context) GetInput() *http.Request
- func (c *Context) GetLogId() string
- func (c *Context) GetMethod() string
- func (c *Context) GetOutput() http.ResponseWriter
- func (c *Context) GetParam(name, dft string) string
- func (c *Context) GetParamAll() map[string]string
- func (c *Context) GetParamArray(name string) []string
- func (c *Context) GetParamMap(name string) map[string]string
- func (c *Context) GetPath() string
- func (c *Context) GetPost(name, dft string) string
- func (c *Context) GetPostAll() map[string]string
- func (c *Context) GetPostArray(name string) []string
- func (c *Context) GetPostMap(name string) map[string]string
- func (c *Context) GetQuery(name, dft string) string
- func (c *Context) GetQueryAll() map[string]string
- func (c *Context) GetQueryArray(name string) []string
- func (c *Context) GetQueryMap(name string) map[string]string
- func (c *Context) GetSize() int
- func (c *Context) GetStatus() int
- func (c *Context) GetUserData(key string, dft interface{}) interface{}
- func (c *Context) Next()
- func (c *Context) SetActionId(id string)
- func (c *Context) SetControllerId(id string)
- func (c *Context) SetCookie(cookie *http.Cookie)
- func (c *Context) SetHeader(name, value string)
- func (c *Context) SetInput(r *http.Request)
- func (c *Context) SetOutput(w http.ResponseWriter)
- func (c *Context) SetUserData(key string, data interface{})
- func (c *Context) ValidateParam(name string, dft ...interface{}) *StringValidator
- func (c *Context) ValidatePost(name string, dft ...interface{}) *StringValidator
- func (c *Context) ValidateQuery(name string, dft ...interface{}) *StringValidator
- type Controller
- func (c *Controller) AfterAction(action string)
- func (c *Controller) BeforeAction(action string)
- func (c *Controller) GetBindInfo(v interface{}) interface{}
- func (c *Controller) HandlePanic(v interface{})
- func (c *Controller) OutputJson(data interface{}, status int, msg ...string)
- func (c *Controller) OutputJsonp(callback string, data interface{}, status int, msg ...string)
- func (c *Controller) OutputView(view string, data interface{}, contentType ...string)
- func (c *Controller) Redirect(location string, permanent bool)
- type Exception
- type File
- type FileTarget
- func (f *FileTarget) Construct()
- func (f *FileTarget) Flush(final bool)
- func (f *FileTarget) Init()
- func (f *FileTarget) Process(item *LogItem)
- func (f *FileTarget) SetFilePath(filePath string)
- func (f *FileTarget) SetMaxBufferByte(maxBufferByte int)
- func (f *FileTarget) SetMaxBufferLine(maxBufferLine int)
- func (f *FileTarget) SetMaxLogFile(maxLogFile int)
- func (f *FileTarget) SetRotate(rotate string)
- type FloatSliceValidator
- type FloatValidator
- type Gzip
- type I18n
- type IBind
- type ICache
- type IConfigParser
- type IController
- type IEvent
- type IFormatter
- type IObject
- type IPlugin
- type ITarget
- type IntSliceValidator
- type IntValidator
- type Item
- type JsonConfigParser
- type JsonValidator
- type Log
- func (d *Log) Construct()
- func (d *Log) Flush()
- func (d *Log) GetLogger(name, logId string) *Logger
- func (d *Log) GetProfiler() *Profiler
- func (d *Log) Init()
- func (d *Log) SetChanLen(len int)
- func (d *Log) SetFlushInterval(v string)
- func (d *Log) SetLevels(v interface{})
- func (d *Log) SetTargets(targets map[string]interface{})
- func (d *Log) SetTraceLevels(v interface{})
- type LogItem
- type Logger
- func (l *Logger) Debug(format string, v ...interface{})
- func (l *Logger) Error(format string, v ...interface{})
- func (l *Logger) Fatal(format string, v ...interface{})
- func (l *Logger) Info(format string, v ...interface{})
- func (l *Logger) Notice(format string, v ...interface{})
- func (l *Logger) Warn(format string, v ...interface{})
- type Map
- type Object
- type Profiler
- func (p *Profiler) Counting(key string, hit, total int)
- func (p *Profiler) GetCountingString() string
- func (p *Profiler) GetProfileString() string
- func (p *Profiler) GetPushLogString() string
- func (p *Profiler) ProfileAdd(key string, elapse time.Duration)
- func (p *Profiler) ProfileStart(key string)
- func (p *Profiler) ProfileStop(key string)
- func (p *Profiler) PushLog(key string, v interface{})
- type Response
- type Router
- type Server
- func (s *Server) Construct()
- func (s *Server) GetStats() *ServerStats
- func (s *Server) HandleRequest(ctx *Context)
- func (s *Server) Serve()
- func (s *Server) ServeCMD()
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetCrtFile(certFile string)
- func (s *Server) SetDebugAddr(addr string)
- func (s *Server) SetEnableAccessLog(v bool)
- func (s *Server) SetHttpAddr(addr string)
- func (s *Server) SetHttpsAddr(addr string)
- func (s *Server) SetKeyFile(keyFile string)
- func (s *Server) SetMaxHeaderBytes(maxBytes int)
- func (s *Server) SetMaxPostBodySize(maxBytes int64)
- func (s *Server) SetPlugins(v []interface{})
- func (s *Server) SetReadTimeout(v string)
- func (s *Server) SetStatsInterval(v string)
- func (s *Server) SetWriteTimeout(v string)
- type ServerStats
- type Status
- type StopBefore
- type StringSliceValidator
- func (s *StringSliceValidator) Do() []string
- func (s *StringSliceValidator) Float() *FloatSliceValidator
- func (s *StringSliceValidator) Int() *IntSliceValidator
- func (s *StringSliceValidator) Len(v int) *StringSliceValidator
- func (s *StringSliceValidator) Max(v int) *StringSliceValidator
- func (s *StringSliceValidator) Min(v int) *StringSliceValidator
- type StringValidator
- func (s *StringValidator) Bool() *BoolValidator
- func (s *StringValidator) Do() string
- func (s *StringValidator) Email() *StringValidator
- func (s *StringValidator) Enum(enums ...string) *StringValidator
- func (s *StringValidator) Filter(f func(v, n string) string) *StringValidator
- func (s *StringValidator) Float() *FloatValidator
- func (s *StringValidator) IPv4() *StringValidator
- func (s *StringValidator) Int() *IntValidator
- func (s *StringValidator) Json() *JsonValidator
- func (s *StringValidator) Len(v int) *StringValidator
- func (s *StringValidator) Max(v int) *StringValidator
- func (s *StringValidator) Min(v int) *StringValidator
- func (s *StringValidator) Mobile() *StringValidator
- func (s *StringValidator) Password() *StringValidator
- func (s *StringValidator) RegExp(v interface{}) *StringValidator
- func (s *StringValidator) Slice(sep string) *StringSliceValidator
- type Target
- type Value
- func (v *Value) Bool() bool
- func (v *Value) Bytes() []byte
- func (v *Value) Data() interface{}
- func (v *Value) Decode(ptr interface{})
- func (v *Value) Encode() []byte
- func (v *Value) Float() float64
- func (v *Value) Int() int
- func (v *Value) MarshalJSON() ([]byte, error)
- func (v *Value) String() string
- func (v *Value) TryDecode(ptr interface{}) (err error)
- func (v *Value) TryEncode() (output []byte, err error)
- func (v *Value) UnmarshalJSON(b []byte) error
- func (v *Value) Valid() bool
- type View
- type YamlConfigParser
Constants ¶
const ( ModeWeb = 1 ModeCmd = 2 DefaultEnv = "develop" DefaultController = "Index" DefaultAction = "Index" DefaultHttpAddr = "0.0.0.0:8000" DefaultTimeout = 30 * time.Second DefaultHeaderBytes = 1 << 20 ControllerWeb = "Controller" ControllerCmd = "Command" ConstructMethod = "Construct" InitMethod = "Init" VendorPrefix = "vendor/" VendorLength = 7 ActionPrefix = "Action" ActionLength = 6 TraceMaxDepth = 10 MaxPlugins = 32 MaxCacheObjects = 100 )
const ( LevelNone = 0x00 LevelDebug = 0x01 LevelInfo = 0x02 LevelNotice = 0x04 LevelWarn = 0x08 LevelError = 0x10 LevelFatal = 0x20 LevelAll = 0xFF )
Variables ¶
var ( App = &Application{} EmptyObject struct{} )
Functions ¶
func Configure ¶
func Configure(obj interface{}, config map[string]interface{})
Configure configure object using the given configuration, obj is a pointer or reflect.Value of a pointer, config is the configuration map for properties.
func ConstructAndInit ¶
func ConstructAndInit(obj interface{}, config map[string]interface{}, params ...interface{})
ConstructAndInit construct and initialize object, obj is a pointer or reflect.Value of a pointer, config is configuration map for properties, params is optional parameters for Construct method.
func CreateObject ¶
func CreateObject(class interface{}, params ...interface{}) interface{}
CreateObject create object using the given configuration, class can be a string or a map contain "class" field, if a map is specified, fields except "class" will be treated as properties of the object to be created, params is optional parameters for Construct method.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application the pgo app, initialization steps: 1. import pgo: pgo.init() 2. customize app: optional 3. pgo.Run(): serve
configuration: name: "app-name" GOMAXPROCS: 2 runtimePath: "@app/runtime" publicPath: "@app/public" viewPath: "@viewPath" container: {} server: {} components: {}
func (*Application) Construct ¶
func (app *Application) Construct()
func (*Application) Get ¶
func (app *Application) Get(id string) interface{}
Get get component by id
func (*Application) GetBasePath ¶
func (app *Application) GetBasePath() string
GetBasePath get base path, default is parent of executable
func (*Application) GetConfig ¶
func (app *Application) GetConfig() *Config
GetConfig get config component
func (*Application) GetContainer ¶
func (app *Application) GetContainer() *Container
GetContainer get container component
func (*Application) GetMode ¶
func (app *Application) GetMode() int
GetMode get running mode, web:1, cmd:2
func (*Application) GetName ¶
func (app *Application) GetName() string
GetName get app name, default is executable name
func (*Application) GetPublicPath ¶
func (app *Application) GetPublicPath() string
GetPublicPath get public path, default is @app/public
func (*Application) GetRouter ¶
func (app *Application) GetRouter() *Router
GetRouter get router component
func (*Application) GetRuntimePath ¶
func (app *Application) GetRuntimePath() string
GetRuntimePath get runtime path, default is @app/runtime
func (*Application) GetServer ¶
func (app *Application) GetServer() *Server
GetServer get server component
func (*Application) GetStatus ¶
func (app *Application) GetStatus() *Status
GetStatus get status component
func (*Application) GetStopBefore ¶
func (app *Application) GetStopBefore() *StopBefore
GetStopBefore get stopBefore component
func (*Application) GetViewPath ¶
func (app *Application) GetViewPath() string
GetViewPath get view path, default is @app/view
func (*Application) Init ¶
func (app *Application) Init()
type BoolValidator ¶
BoolValidator validator for bool value
func ValidateBool ¶
func ValidateBool(data interface{}, name string, dft ...interface{}) *BoolValidator
validate bool value
func (*BoolValidator) Do ¶
func (b *BoolValidator) Do() bool
func (*BoolValidator) Must ¶
func (b *BoolValidator) Must(v bool) *BoolValidator
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config the config component
func (*Config) AddParser ¶
func (c *Config) AddParser(ext string, parser IConfigParser)
AddParser add parser for file with ext extension
func (*Config) Get ¶
Get get value by dot separated key, the first part of key is file name without extension. if key is empty, all loaded config will be returned.
func (*Config) GetBool ¶
GetBool get bool value from config, key is dot separated config key, dft is default value if key not exists.
func (*Config) GetFloat ¶
GetFloat get float value from config, key is dot separated config key, dft is default value if key not exists.
func (*Config) GetInt ¶
GetInt get int value from config, key is dot separated config key, dft is default value if key not exists.
func (*Config) GetSliceBool ¶ added in v0.1.4
GetSliceBool get []bool value from config, key is dot separated config key, nil is default value if key not exists.
func (*Config) GetSliceFloat ¶ added in v0.1.4
GetSliceFloat get []float value from config, key is dot separated config key, nil is default value if key not exists.
func (*Config) GetSliceInt ¶ added in v0.1.4
GetSliceInt get []int value from config, key is dot separated config key, nil is default value if key not exists.
func (*Config) GetSliceString ¶ added in v0.1.4
GetSliceString get []string value from config, key is dot separated config key, nil is default value if key not exists.
func (*Config) GetString ¶
GetString get string value from config, key is dot separated config key, dft is default value if key not exists.
type ConsoleTarget ¶
type ConsoleTarget struct {
Target
}
ConsoleTarget target for console
func (*ConsoleTarget) Construct ¶
func (c *ConsoleTarget) Construct()
func (*ConsoleTarget) Process ¶
func (c *ConsoleTarget) Process(item *LogItem)
Process write log to stdout
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container the container component, configuration: container:
enablePool: true
func (*Container) Bind ¶
func (c *Container) Bind(i interface{})
Bind bind template object to class, param i must be a pointer of struct.
func (*Container) Get ¶
func (c *Container) Get(name string, config map[string]interface{}, params ...interface{}) reflect.Value
Get get new class object. name is class name, config is properties map, params is optional construct parameters.
func (*Container) SetEnablePool ¶
SetEnablePool set context based object pool enable or not, default is enabled.
type Context ¶
Context pgo request context, context is not goroutine safe, copy context to use in other goroutines
func (*Context) GetCookieAll ¶
GetCookieAll get first value of all cookies
func (*Context) GetElapseMs ¶
GetElapseMs get elapsed ms since request start
func (*Context) GetHeaderAll ¶
GetHeaderAll get first value of all headers
func (*Context) GetParamAll ¶
GetParamAll get first value of all params, post take precedence over get
func (*Context) GetParamArray ¶
GetParamArray get array value from GET/POST
func (*Context) GetParamMap ¶
GetParamMap get map value from GET/POST
func (*Context) GetPostAll ¶
GetPostAll get first value of all posts
func (*Context) GetPostArray ¶
GetPostArray get array value from POST
func (*Context) GetPostMap ¶
GetPostMap get map value from POST
func (*Context) GetQueryAll ¶
GetQueryAll get first value of all url queries
func (*Context) GetQueryArray ¶
GetQueryArray get array value from GET
func (*Context) GetQueryMap ¶
GetQueryMap get map value from GET
func (*Context) GetUserData ¶
GetUserData get user data from current context
func (*Context) SetUserData ¶
SetUserData set user data to current context
func (*Context) ValidateParam ¶
func (c *Context) ValidateParam(name string, dft ...interface{}) *StringValidator
validate get/post param, return string validator
func (*Context) ValidatePost ¶
func (c *Context) ValidatePost(name string, dft ...interface{}) *StringValidator
validate post param, return string validator
func (*Context) ValidateQuery ¶
func (c *Context) ValidateQuery(name string, dft ...interface{}) *StringValidator
validate query param, return string validator
type Controller ¶
type Controller struct {
Object
}
Controller the base class of web and cmd controller
func (*Controller) AfterAction ¶
func (c *Controller) AfterAction(action string)
AfterAction after action hook
func (*Controller) BeforeAction ¶
func (c *Controller) BeforeAction(action string)
BeforeAction before action hook
func (*Controller) GetBindInfo ¶
func (c *Controller) GetBindInfo(v interface{}) interface{}
GetBindInfo get action map as extra binding info
func (*Controller) HandlePanic ¶
func (c *Controller) HandlePanic(v interface{})
HandlePanic process unhandled action panic
func (*Controller) OutputJson ¶
func (c *Controller) OutputJson(data interface{}, status int, msg ...string)
OutputJson output json response
func (*Controller) OutputJsonp ¶
func (c *Controller) OutputJsonp(callback string, data interface{}, status int, msg ...string)
OutputJsonp output jsonp response
func (*Controller) OutputView ¶
func (c *Controller) OutputView(view string, data interface{}, contentType ...string)
OutputView output rendered view
func (*Controller) Redirect ¶
func (c *Controller) Redirect(location string, permanent bool)
Redirect output redirect response
type Exception ¶
type Exception struct {
// contains filtered or unexported fields
}
Exception panic as exception
func NewException ¶
NewException create new exception with status and message
func (*Exception) GetMessage ¶
GetMessage get exception message string
type File ¶
type File struct {
// contains filtered or unexported fields
}
File file plugin, this plugin only handle file in @public directory, request url with empty or excluded extension will not be handled.
func (*File) HandleRequest ¶
func (*File) SetExcludeExtensions ¶
func (f *File) SetExcludeExtensions(v []interface{})
type FileTarget ¶
type FileTarget struct { Target // contains filtered or unexported fields }
FileTarget target for file, configuration: info:
class: "@pgo/FileTarget" levels: "DEBUG,INFO,NOTICE" filePath: "@runtime/info.log" maxLogFile: 10 maxBufferByte: 10485760 maxBufferLine: 10000 rotate: "daily"
func (*FileTarget) Construct ¶
func (f *FileTarget) Construct()
func (*FileTarget) Init ¶
func (f *FileTarget) Init()
func (*FileTarget) Process ¶
func (f *FileTarget) Process(item *LogItem)
Process check and rotate log file if rotate is enable, write log to buffer, flush buffer to file if buffer is full.
func (*FileTarget) SetFilePath ¶
func (f *FileTarget) SetFilePath(filePath string)
SetFilePath set file path, default "@runtime/app.log"
func (*FileTarget) SetMaxBufferByte ¶
func (f *FileTarget) SetMaxBufferByte(maxBufferByte int)
SetMaxBufferByte set max buffer bytes, default 10MB
func (*FileTarget) SetMaxBufferLine ¶
func (f *FileTarget) SetMaxBufferLine(maxBufferLine int)
SetMaxBufferLine set max buffer lines, default 10000
func (*FileTarget) SetMaxLogFile ¶
func (f *FileTarget) SetMaxLogFile(maxLogFile int)
SetMaxLogFile set max log backups, default 10
func (*FileTarget) SetRotate ¶
func (f *FileTarget) SetRotate(rotate string)
SetRotate set rotate policy(none, hourly, daily), default "daily"
type FloatSliceValidator ¶
FloatSliceValidator validator for float slice value
func (*FloatSliceValidator) Do ¶
func (f *FloatSliceValidator) Do() []float64
type FloatValidator ¶
FloatValidator validator for float value
func ValidateFloat ¶
func ValidateFloat(data interface{}, name string, dft ...interface{}) *FloatValidator
validate float value
func (*FloatValidator) Do ¶
func (f *FloatValidator) Do() float64
func (*FloatValidator) Max ¶
func (f *FloatValidator) Max(v float64) *FloatValidator
func (*FloatValidator) Min ¶
func (f *FloatValidator) Min(v float64) *FloatValidator
type Gzip ¶
type Gzip struct {
// contains filtered or unexported fields
}
Gzip gzip compression plugin
func (*Gzip) HandleRequest ¶
type I18n ¶
type I18n struct {
// contains filtered or unexported fields
}
I18n the internationalization component, language format is ll-CC or ll, lower case lang code, upper case area code. lang file name format is i18n_{lang}.json, and located in conf directory, configuration: i18n:
sourceLang: "en" targetLang: [ "en", "zh-CN", "zh-TW"]
func (*I18n) SetSourceLang ¶
SetSourceLang set language of source
func (*I18n) SetTargetLang ¶
func (i *I18n) SetTargetLang(targets []interface{})
SetTargetLang set language of target
type ICache ¶
type ICache interface { Get(key string) *Value MGet(keys []string) map[string]*Value Set(key string, value interface{}, expire ...time.Duration) bool MSet(items map[string]interface{}, expire ...time.Duration) bool Add(key string, value interface{}, expire ...time.Duration) bool MAdd(items map[string]interface{}, expire ...time.Duration) bool Del(key string) bool MDel(keys []string) bool Exists(key string) bool Incr(key string, delta int) int }
type IConfigParser ¶
type IController ¶
type IFormatter ¶
type IntSliceValidator ¶
IntSliceValidator validator for int slice value
func (*IntSliceValidator) Do ¶
func (i *IntSliceValidator) Do() []int
type IntValidator ¶
IntValidator validator for int value
func ValidateInt ¶
func ValidateInt(data interface{}, name string, dft ...interface{}) *IntValidator
validate int value
func (*IntValidator) Do ¶
func (i *IntValidator) Do() int
func (*IntValidator) Enum ¶
func (i *IntValidator) Enum(enums ...int) *IntValidator
func (*IntValidator) Max ¶
func (i *IntValidator) Max(v int) *IntValidator
func (*IntValidator) Min ¶
func (i *IntValidator) Min(v int) *IntValidator
type JsonConfigParser ¶
type JsonConfigParser struct { }
JsonConfigParser parser for json config
func (*JsonConfigParser) Parse ¶
func (j *JsonConfigParser) Parse(path string) map[string]interface{}
Parse parse json config, environment value like ${env||default} will expand
type JsonValidator ¶
JsonValidator validator for json value
func (*JsonValidator) Do ¶
func (j *JsonValidator) Do() map[string]interface{}
func (*JsonValidator) Has ¶
func (j *JsonValidator) Has(key string) *JsonValidator
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log the log component, configuration: log:
levels: "ALL" traceLevels: "DEBUG" chanLen: 1000 flushInterval: "60s" targets: info: class: "@pgo/FileTarget" levels: "DEBUG,INFO,NOTICE" filePath: "@runtime/info.log" maxLogFile: 10 rotate: "daily" error: { class: "@pgo/FileTarget" levels: "WARN,ERROR,FATAL" filePath: "@runtime/error.log" maxLogFile: 10 rotate: "daily"
func (*Log) SetChanLen ¶
SetChanLen set length of log channel, default 1000
func (*Log) SetFlushInterval ¶
SetFlushInterval set interval to flush log, default "60s"
func (*Log) SetLevels ¶
func (d *Log) SetLevels(v interface{})
SetLevels set levels to handle, default "ALL"
func (*Log) SetTargets ¶
SetTargets set output target, ConsoleTarget will be used if no targets specified
func (*Log) SetTraceLevels ¶
func (d *Log) SetTraceLevels(v interface{})
SetTraceLevels set levels to trace, default "DEBUG"
type LogItem ¶
type LogItem struct { When time.Time Level int Name string LogId string Trace string Message string }
LogItem represent an item of log
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object base class of context based object
func (*Object) GetContext ¶
GetContext get context of this object
func (*Object) GetObject ¶
func (o *Object) GetObject(class interface{}, params ...interface{}) interface{}
GetObject create new object and inject context
func (*Object) SetContext ¶
SetContext set context of this object
type Profiler ¶
type Profiler struct {
// contains filtered or unexported fields
}
Profiler
func (*Profiler) Counting ¶
Counting add counting info, the counting string is key=sum(hit)/sum(total)
func (*Profiler) GetCountingString ¶
GetCountingString get counting info string
func (*Profiler) GetProfileString ¶
GetProfileString get profile info string
func (*Profiler) GetPushLogString ¶
GetPushLogString get push log string
func (*Profiler) ProfileAdd ¶
ProfileAdd add profile info, the profile string is key=sum(elapse)/count
func (*Profiler) ProfileStart ¶
ProfileStart mark start of profile
func (*Profiler) ProfileStop ¶
ProfileStop mark stop of profile
type Response ¶
type Response struct { http.ResponseWriter // contains filtered or unexported fields }
Response http.ResponseWriter wrapper
func (*Response) ReadFrom ¶
ReadFrom is here to optimize copying from a regular file to a *net.TCPConn with sendfile.
func (*Response) Write ¶
Write write data to underlying http.ResponseWriter and record num bytes that has written.
func (*Response) WriteHeader ¶
WriteHeader cache status code until first write operation.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router the router component, configuration: router:
rules: - "^/foo/all$ => /foo/index" - "^/api/user/(\d+)$ => /api/user"
func (*Router) AddRoute ¶
AddRoute add one route, the captured group will be passed to action method as function params
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server the server component, configuration: server:
httpAddr: "0.0.0.0:8000" debugAddr: "0.0.0.0:8100" httpsAddr: "0.0.0.0:8443" crtFile: "@app/conf/site.crt" keyFile: "@app/conf/site.key" maxHeaderBytes: 1048576 readTimeout: "30s" writeTimeout: "30s" statsInterval: "60s" enableAccessLog: true maxPostBodySize: 1048576
func (*Server) HandleRequest ¶
HandleRequest handle request of cmd or http, this method called in the last of plugin chain.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serve http request
func (*Server) SetCrtFile ¶
SetCrtFile set certificate file for https
func (*Server) SetDebugAddr ¶
SetDebugAddr set debug and pprof addr.
func (*Server) SetEnableAccessLog ¶
SetEnableAccessLog set access log enable or not
func (*Server) SetHttpAddr ¶
SetHttpAddr set http addr, if both httpAddr and httpsAddr are empty, "0.0.0.0:8000" will be used as httpAddr.
func (*Server) SetHttpsAddr ¶
SetHttpsAddr set https addr.
func (*Server) SetKeyFile ¶
SetKeyFile set private key file for https
func (*Server) SetMaxHeaderBytes ¶
SetMaxHeaderBytes set max header bytes
func (*Server) SetMaxPostBodySize ¶
SetMaxPostBodySize set max header bytes
func (*Server) SetPlugins ¶
func (s *Server) SetPlugins(v []interface{})
SetPlugins set plugin names
func (*Server) SetReadTimeout ¶
SetReadTimeout set timeout to read request
func (*Server) SetStatsInterval ¶
SetStatsInterval set interval to output stats
func (*Server) SetWriteTimeout ¶
SetWriteTimeout set timeout to write response
type ServerStats ¶
type ServerStats struct { MemMB uint // memory obtained from os NumReq uint64 // number of handled requests NumGO uint // number of goroutines NumGC uint // number of gc runs TimeGC string // total time of gc pause TimeRun string // total time of app runs }
ServerStats server stats
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status the status component, configuration: status:
useI18n: false mapping: 11002: "Verify Sign Error"
func (*Status) SetMapping ¶
SetMapping set mapping from status code to text
func (*Status) SetUseI18n ¶
SetUseI18n set whether to use i18n translation
type StopBefore ¶
type StopBefore struct {
// contains filtered or unexported fields
}
func (*StopBefore) Add ¶
func (s *StopBefore) Add(obj interface{}, method string, dfParams ...[]interface{})
增加停止前执行的对象和方法
type StringSliceValidator ¶
StringSliceValidator validator for string slice value
func (*StringSliceValidator) Do ¶
func (s *StringSliceValidator) Do() []string
func (*StringSliceValidator) Float ¶
func (s *StringSliceValidator) Float() *FloatSliceValidator
func (*StringSliceValidator) Int ¶
func (s *StringSliceValidator) Int() *IntSliceValidator
func (*StringSliceValidator) Len ¶
func (s *StringSliceValidator) Len(v int) *StringSliceValidator
func (*StringSliceValidator) Max ¶
func (s *StringSliceValidator) Max(v int) *StringSliceValidator
func (*StringSliceValidator) Min ¶
func (s *StringSliceValidator) Min(v int) *StringSliceValidator
type StringValidator ¶
StringValidator validator for string value
func ValidateString ¶
func ValidateString(data interface{}, name string, dft ...interface{}) *StringValidator
validate string value
func (*StringValidator) Bool ¶
func (s *StringValidator) Bool() *BoolValidator
func (*StringValidator) Do ¶
func (s *StringValidator) Do() string
func (*StringValidator) Email ¶
func (s *StringValidator) Email() *StringValidator
func (*StringValidator) Enum ¶
func (s *StringValidator) Enum(enums ...string) *StringValidator
func (*StringValidator) Filter ¶
func (s *StringValidator) Filter(f func(v, n string) string) *StringValidator
func (*StringValidator) Float ¶
func (s *StringValidator) Float() *FloatValidator
func (*StringValidator) IPv4 ¶
func (s *StringValidator) IPv4() *StringValidator
func (*StringValidator) Int ¶
func (s *StringValidator) Int() *IntValidator
func (*StringValidator) Json ¶
func (s *StringValidator) Json() *JsonValidator
func (*StringValidator) Len ¶
func (s *StringValidator) Len(v int) *StringValidator
func (*StringValidator) Max ¶
func (s *StringValidator) Max(v int) *StringValidator
func (*StringValidator) Min ¶
func (s *StringValidator) Min(v int) *StringValidator
func (*StringValidator) Mobile ¶
func (s *StringValidator) Mobile() *StringValidator
func (*StringValidator) Password ¶
func (s *StringValidator) Password() *StringValidator
func (*StringValidator) RegExp ¶
func (s *StringValidator) RegExp(v interface{}) *StringValidator
func (*StringValidator) Slice ¶
func (s *StringValidator) Slice(sep string) *StringSliceValidator
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
Target base class of output
func (*Target) IsHandling ¶
IsHandling check whether this target is handling the log item
func (*Target) SetFormatter ¶
func (t *Target) SetFormatter(v interface{})
SetFormatter set user-defined log formatter, eg. "Lib/Log/Formatter"
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value adapter for value of any type, provide uniform encoding and decoding.
func (*Value) Decode ¶
func (v *Value) Decode(ptr interface{})
Decode decode data bytes to ptr, panic if failed
func (*Value) MarshalJSON ¶
func (*Value) UnmarshalJSON ¶
type View ¶
type View struct {
// contains filtered or unexported fields
}
View the view component, configuration: view:
suffix: ".html" commons: - "@view/common/header.html" - "@view/common/footer.html"
func (*View) AddFuncMap ¶
AddFuncMap add custom func map
func (*View) SetCommons ¶
func (v *View) SetCommons(commons []interface{})
SetCommons set common view files
type YamlConfigParser ¶
type YamlConfigParser struct { }
YamlConfigParser parser for yaml config
func (*YamlConfigParser) Parse ¶
func (y *YamlConfigParser) Parse(path string) map[string]interface{}
Parse parse yaml config, environment value like ${env||default} will expand