Documentation ¶
Index ¶
- Constants
- func MarshalJSON(v interface{}) (out []byte, err error)
- func MarshalJSONString(v interface{}) (out string)
- func MarshalXML(v interface{}) (out []byte, err error)
- func MarshalXMLString(v interface{}) (out string)
- func MarshalYaml(v interface{}) (out []byte, err error)
- func MarshalYamlString(v interface{}) (out string)
- func ParseConfigSetJSON(configFile string) (core.ConcurrenceMap, error)
- func ParseConfigSetXML(configFile string) (core.ConcurrenceMap, error)
- func ParseConfigSetYaml(configFile string) (core.ConcurrenceMap, error)
- func UnmarshalJSON(content []byte, v interface{}) error
- func UnmarshalXML(content []byte, v interface{}) error
- func UnmarshalYaml(content []byte, v interface{}) error
- type AppNode
- type Config
- type ConfigSet
- type ConfigSetNode
- type GroupNode
- type MiddlewareNode
- type RouterNode
- type ServerNode
- type SessionNode
Constants ¶
const ( // ConfigType_XML xml config file ConfigType_XML = "xml" // ConfigType_JSON json config file ConfigType_JSON = "json" // ConfigType_Yaml yaml config file ConfigType_Yaml = "yaml" )
const (
// default timeout Millisecond for per request handler
DefaultRequestTimeOut = 30000
)
Variables ¶
This section is empty.
Functions ¶
func MarshalJSON ¶
MarshalJSON returns the JSON encoding of v.
func MarshalJSONString ¶
func MarshalJSONString(v interface{}) (out string)
MarshalJSONString returns the JSON encoding string format of v.
func MarshalXML ¶
MarshalXML returns the XML encoding of v.
func MarshalXMLString ¶
func MarshalXMLString(v interface{}) (out string)
MarshalXMLString returns the XML encoding string format of v.
func MarshalYaml ¶
MarshalYaml Marshal serializes the value provided into a YAML document. For example:
type T struct { F int "a,omitempty" B int } yaml.Marshal(&T{B: 2}) // Returns "b: 2\n" yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n"
func MarshalYamlString ¶
func MarshalYamlString(v interface{}) (out string)
MarshalYamlString returns the Ymal encoding string format of v.
func ParseConfigSetJSON ¶
func ParseConfigSetJSON(configFile string) (core.ConcurrenceMap, error)
ParseConfigSetJSON include ConfigSet json file
func ParseConfigSetXML ¶
func ParseConfigSetXML(configFile string) (core.ConcurrenceMap, error)
ParseConfigSetXML include ConfigSet xml file
func ParseConfigSetYaml ¶
func ParseConfigSetYaml(configFile string) (core.ConcurrenceMap, error)
ParseConfigSetYaml include ConfigSet yaml file
func UnmarshalJSON ¶
UnmarshalJSON parses the JSON-encoded data and stores the result in the value pointed to by v.
func UnmarshalXML ¶
UnmarshalXML parses the XML-encoded data and stores the result in the value pointed to by v, which must be an arbitrary struct, slice, or string. Well-formed data that does not fit into v is discarded.
func UnmarshalYaml ¶
UnmarshalYaml decodes the first document found within the in byte slice and assigns decoded values into the out value. For example:
type T struct { F int `yaml:"a,omitempty"` B int } var t T yaml.Unmarshal([]byte("a: 1\nb: 2"), &t)
Types ¶
type AppNode ¶
type AppNode struct { LogPath string `xml:"logpath,attr"` // path of log files, use current directory if empty EnabledLog bool `xml:"enabledlog,attr"` // enable logging RunMode string `xml:"runmode,attr"` // run mode, currently supports [development, production] PProfPort int `xml:"pprofport,attr"` // pprof-server port, cann't be same as server port EnabledPProf bool `xml:"enabledpprof,attr"` // enable pprof server, default is false }
AppNode dotweb app global config
func NewAppNode ¶
func NewAppNode() *AppNode
type Config ¶
type Config struct { XMLName xml.Name `xml:"config" json:"-" yaml:"-"` App *AppNode `xml:"app"` ConfigSetNodes []*ConfigSetNode `xml:"configset>set"` Server *ServerNode `xml:"server"` Session *SessionNode `xml:"session"` Routers []*RouterNode `xml:"routers>router"` Groups []*GroupNode `xml:"groups>group"` Middlewares []*MiddlewareNode `xml:"middlewares>middleware"` ConfigSet core.ReadonlyMap `json:"-" yaml:"-"` ConfigFilePath string ConfigType string }
Config dotweb app config define
func InitConfig ¶
InitConfig initialize the config with configFile
func MustInitConfig ¶
init config file If an exception occurs, will be panic it
type ConfigSet ¶
type ConfigSet struct { XMLName xml.Name `xml:"config" json:"-" yaml:"-"` Name string `xml:"name,attr"` ConfigSetNodes []*ConfigSetNode `xml:"set"` }
ConfigSet set of config nodes
type ConfigSetNode ¶
ConfigSetNode update for issue #16 config file
type GroupNode ¶
type GroupNode struct { Path string `xml:"path,attr"` Routers []*RouterNode `xml:"router"` Middlewares []*MiddlewareNode `xml:"middleware"` IsUse bool `xml:"isuse,attr"` // enable group, default is false }
GroupNode dotweb app's group router config
type MiddlewareNode ¶
type MiddlewareNode struct { Name string `xml:"name,attr"` IsUse bool `xml:"isuse,attr"` // enable middleware, default is false }
MiddlewareNode dotweb app's middleware config
type RouterNode ¶
type RouterNode struct { Method string `xml:"method,attr"` Path string `xml:"path,attr"` HandlerName string `xml:"handler,attr"` Middlewares []*MiddlewareNode `xml:"middleware"` IsUse bool `xml:"isuse,attr"` // enable router, default is false }
RouterNode dotweb app's router config
type ServerNode ¶
type ServerNode struct { EnabledListDir bool `xml:"enabledlistdir,attr"` // enable listing of directories, only valid for Router.ServerFile, default is false EnabledRequestID bool `xml:"enabledrequestid,attr"` // enable uniq request ID, default is false, 32-bit UUID is used if enabled EnabledGzip bool `xml:"enabledgzip,attr"` // enable gzip EnabledAutoHEAD bool `xml:"enabledautohead,attr"` // ehanble HEAD routing, default is false, will add HEAD routing for all routes except for websocket and HEAD EnabledAutoOPTIONS bool // enable OPTIONS routing, default is false, will add OPTIONS routing for all routes except for websocket and OPTIONS EnabledIgnoreFavicon bool `xml:"enabledignorefavicon,attr"` // ignore favicon.ico request, return empty reponse if set EnabledBindUseJsonTag bool `xml:"enabledbindusejsontag,attr"` // allow Bind to use JSON tag, default is false, Bind will use json tag automatically and ignore form tag EnabledStaticFileMiddleware bool // The flag which enabled or disabled middleware for static-file route Port int `xml:"port,attr"` // port EnabledTLS bool `xml:"enabledtls,attr"` // enable TLS TLSCertFile string `xml:"tlscertfile,attr"` // certifications file for TLS TLSKeyFile string `xml:"tlskeyfile,attr"` // keys file for TLS IndexPage string `xml:"IndexPage,attr"` // default index page EnabledDetailRequestData bool `xml:"EnabledDetailRequestData,attr"` // enable detailed statics for requests, default is false. Please use with care, it will have performance issues if the site have lots of URLs VirtualPath string `xml:"VirtualPath,attr"` // virtual path when deploy on no root path // To limit the request's body size to be read // which can avoid unexpected or malicious request to cause the service's OOM // default is 32 << 20 (32 mb), MaxBodySize use go runtime default zero value // -1 : unlimted // 0 : use default value MaxBodySize int64 `xml:"MaxBodySize,attr"` // To limit the request's body size to be read with Millisecond // ReadTimeout is the maximum duration for reading the entire // request, including the body. ReadTimeout int64 `xml:"ReadTimeout,attr"` // ReadHeaderTimeout is the amount of time allowed to read // request headers with Millisecond. The connection's read deadline is reset // after reading the headers and the Handler can decide what // is considered too slow for the body. ReadHeaderTimeout int64 `xml:"ReadHeaderTimeout,attr"` // WriteTimeout is the maximum duration before timing out // writes of the response with Millisecond. It is reset whenever a new // request's header is read. Like ReadTimeout, it does not // let Handlers make decisions on a per-request basis. WriteTimeout int64 `xml:"WriteTimeout,attr"` // IdleTimeout is the maximum amount of time to wait for the // next request when keep-alives are enabled with Millisecond. If IdleTimeout // is zero, the value of ReadTimeout is used. If both are // zero, ReadHeaderTimeout is used. IdleTimeout int64 `xml:"IdleTimeout,attr"` }
ServerNode dotweb app's httpserver config
func NewServerNode ¶
func NewServerNode() *ServerNode
type SessionNode ¶
type SessionNode struct { EnabledSession bool `xml:"enabled,attr"` // enable session SessionMode string `xml:"mode,attr"` // session mode,now support runtime、redis CookieName string `xml:"cookiename,attr"` // custom cookie name which sessionid store, default is dotweb_sessionId Timeout int64 `xml:"timeout,attr"` // session time-out period, with second ServerIP string `xml:"serverip,attr"` // remote session server url BackupServerUrl string `xml:"backupserverurl,attr"` // backup remote session server url StoreKeyPre string `xml:"storekeypre,attr"` // remote session StoreKeyPre MaxIdle int `xml:"maxidle,attr"` // remote session MaxIdle MaxActive int `xml:"maxactive,attr"` // remote session MaxActive }
SessionNode dotweb app's session config
func NewSessionNode ¶
func NewSessionNode() *SessionNode