config

package
v0.0.0-...-2e696e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigType_Xml  = "xml"
	ConfigType_Json = "json"
)

Variables

This section is empty.

Functions

This section is empty.

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,默认不启用
}

func NewAppNode

func NewAppNode() *AppNode

type AppSetNode

type AppSetNode struct {
	Key   string `xml:"key,attr"`
	Value string `xml:"value,attr"`
}

update for issue #16 配置文件

type Config

type Config struct {
	XMLName      xml.Name          `xml:"config" json:"-"`
	App          *AppNode          `xml:"app"`
	AppSets      []*AppSetNode     `xml:"appset>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"`
	AppSetConfig *core.ItemContext
}

func InitConfig

func InitConfig(configFile string, confType ...interface{}) (config *Config, err error)

初始化配置文件 如果发生异常,返回异常

func MustInitConfig

func MustInitConfig(configFile string, confType ...interface{}) *Config

init config file If an exception occurs, will be panic it

func NewConfig

func NewConfig() *Config

type GroupNode

type GroupNode struct {
	Path        string            `xml:"path,attr"`
	Routers     []*RouterNode     `xml:"router"`
	Middlewares []*MiddlewareNode `xml:"middleware"`
	IsUse       bool              `xml:"isuse,attr"` //是否启用,默认false
}

type MiddlewareNode

type MiddlewareNode struct {
	Name  string `xml:"name,attr"`
	IsUse bool   `xml:"isuse,attr"` //是否启用,默认false
}

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
}

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
}

type ServerNode

type ServerNode struct {
	EnabledListDir  bool `xml:"enabledlistdir,attr"`  //设置是否启用目录浏览,仅对Router.ServerFile有效,若设置该项,则可以浏览目录文件,默认不开启
	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”全部请求均支持跨域
	Port            int  `xml:"port,attr"`            //端口
}

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
}

func NewSessionNode

func NewSessionNode() *SessionNode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL