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 OfflineNode
- 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"` //文件方式日志目录,如果为空,默认当前目录 EnabledLog bool `xml:"enabledlog,attr"` //是否启用日志记录 RunMode string `xml:"runmode,attr"` //运行模式,目前支持development、production PProfPort int `xml:"pprofport,attr"` //pprof-server 端口,不能与主Server端口相同 EnabledPProf bool `xml:"enabledpprof,attr"` //是否启用pprof server,默认不启用 }
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"` Offline *OfflineNode `xml:"offline"` 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:"-"` }
Config dotweb app config define
func InitConfig ¶
初始化配置文件 如果发生异常,返回异常
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 单元配置组,包含一系列单元配置节点
type ConfigSetNode ¶
ConfigSetNode update for issue #16 配置文件
type GroupNode ¶
type GroupNode struct { Path string `xml:"path,attr"` Routers []*RouterNode `xml:"router"` Middlewares []*MiddlewareNode `xml:"middleware"` IsUse bool `xml:"isuse,attr"` //是否启用,默认false }
GroupNode dotweb app's group router config
type MiddlewareNode ¶
type MiddlewareNode struct { Name string `xml:"name,attr"` IsUse bool `xml:"isuse,attr"` //是否启用,默认false }
MiddlewareNode dotweb app's middleware config
type OfflineNode ¶
type OfflineNode struct { Offline bool `xml:"offline,attr"` //是否维护,默认false OfflineText string `xml:"offlinetext,attr"` //当设置为维护,默认显示内容,如果设置url,优先url OfflineUrl string `xml:"offlineurl,attr"` //当设置为维护,默认维护页地址,如果设置url,优先url }
OfflineNode dotweb app offline config
func NewOfflineNode ¶
func NewOfflineNode() *OfflineNode
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"` //是否启用,默认false }
RouterNode dotweb app's router config
type ServerNode ¶
type ServerNode struct { EnabledListDir bool `xml:"enabledlistdir,attr"` //设置是否启用目录浏览,仅对Router.ServerFile有效,若设置该项,则可以浏览目录文件,默认不开启 EnabledRequestID bool `xml:"enabledrequestid,attr"` //设置是否启用唯一请求ID,默认不开启,开启后使用32位UUID EnabledGzip bool `xml:"enabledgzip,attr"` //是否启用gzip EnabledAutoHEAD bool `xml:"enabledautohead,attr"` //设置是否自动启用Head路由,若设置该项,则会为除Websocket\HEAD外所有路由方式默认添加HEAD路由,默认不开启 EnabledAutoCORS bool `xml:"enabledautocors,attr"` //设置是否自动跨域支持,若设置,默认“GET, POST, PUT, DELETE, OPTIONS”全部请求均支持跨域 EnabledIgnoreFavicon bool `xml:"enabledignorefavicon,attr"` //设置是否忽略favicon.ico请求,若设置,网站将把所有favicon.ico请求直接空返回 EnabledBindUseJsonTag bool `xml:"enabledbindusejsontag,attr"` //设置bind是否启用json标签,默认不启用,若设置,bind自动识别json tag,忽略form tag Port int `xml:"port,attr"` //端口 EnabledTLS bool `xml:"enabledtls,attr"` //是否启用TLS模式 TLSCertFile string `xml:"tlscertfile,attr"` //TLS模式下Certificate证书文件地址 TLSKeyFile string `xml:"tlskeyfile,attr"` //TLS模式下秘钥文件地址 IndexPage string `xml:"indexpage,attr"` //默认index页面 EnabledDetailRequestData bool `xml:"enableddetailrequestdata,attr"` //设置状态数据是否启用详细页面统计,默认不启用,请特别对待,如果站点url过多,会导致数据量过大 }
ServerNode dotweb app's httpserver config
func NewServerNode ¶
func NewServerNode() *ServerNode
type SessionNode ¶
type SessionNode struct { EnabledSession bool `xml:"enabled,attr"` //启用Session SessionMode string `xml:"mode,attr"` //session模式,目前支持runtime、redis Timeout int64 `xml:"timeout,attr"` //session超时时间,分为单位 ServerIP string `xml:"serverip,attr"` //远程session serverip UserName string `xml:"username,attr"` //远程session username Password string `xml:"password,attr"` //远程session password }
SessionNode dotweb app's session config
func NewSessionNode ¶
func NewSessionNode() *SessionNode