Documentation
¶
Overview ¶
Package webconfig 配置文件对应的内容。
Index ¶
- type Duration
- func (d Duration) Duration() time.Duration
- func (d Duration) MarshalJSON() ([]byte, error)
- func (d Duration) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (d Duration) MarshalYAML() (interface{}, error)
- func (d *Duration) UnmarshalJSON(b []byte) error
- func (d *Duration) UnmarshalXML(de *xml.Decoder, start xml.StartElement) error
- func (d *Duration) UnmarshalYAML(u func(interface{}) error) error
- type WebConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶ added in v0.26.0
Duration 封装 time.Duration,实现 JSON、XML 和 YAML 的解析
func (Duration) MarshalJSON ¶ added in v0.26.0
MarshalJSON json.Marshaler 接口
func (Duration) MarshalXML ¶ added in v0.26.0
MarshalXML xml.Marshaler 接口
func (Duration) MarshalYAML ¶ added in v0.26.0
MarshalYAML yaml.Marshaler 接口
func (*Duration) UnmarshalJSON ¶ added in v0.26.0
UnmarshalJSON json.Unmarshaler 接口
func (*Duration) UnmarshalXML ¶ added in v0.26.0
UnmarshalXML xml.Unmarshaler 接口
func (*Duration) UnmarshalYAML ¶ added in v0.26.0
UnmarshalYAML yaml.Unmarshaler 接口
type WebConfig ¶
type WebConfig struct { XMLName struct{} `yaml:"-" json:"-" xml:"webconfig"` // Domain 网站的主域名 // // 必须为一个合法的域名、IP 或是 localhost 字符串。 // // 当 AllowedDomain 值不为空时,此值会自动合并到 AllowedDomains 中。 Domain string `yaml:"domain,omitempty" json:"domain,omitempty" xml:"domain,omitempty"` // Debug 是否启用调试模式 // // 该值可能会同时影响多个方面,比如是否启用 Pprof、panic 时的输出处理等 Debug bool `yaml:"debug,omitempty" json:"debug,omitempty" xml:"debug,attr,omitempty"` // Root 表示网站所在的根目录 // // 当网站不在根目录下时,需要指定 Root,比如将网站部署在:example.com/blog // 则除了将 Domain 的值设置为 example.com 之外,也要将 Root 的值设置为 /blog。 // // Root 值的格式必须为以 / 开头,不以 / 结尾,或是空值。 Root string `yaml:"root,omitempty" json:"root,omitempty" xml:"root,omitempty"` // Plugins 指定插件,通过 glob 语法指定,比如:~/plugins/*.so // 为空表示没有插件。 // // 当前仅支持部分系统:https://golang.org/pkg/plugin/ Plugins string `yaml:"plugins,omitempty" json:"plugins,omitempty" xml:"plugins,omitempty"` // HTTPS 是否启用 HTTPS 协议 // // 如果启用此配置,则需要保证 CertFile 和 KeyFile 两个文件必须存在, // 这两个文件最终会被传递给 http.ListenAndServeTLS() 的两个参数。 // // 此值还会影响 Port 的默认值。 HTTPS bool `yaml:"https,omitempty" json:"https,omitempty" xml:"https,omitempty"` CertFile string `yaml:"certFile,omitempty" json:"certFile,omitempty" xml:"certFile,omitempty"` KeyFile string `yaml:"keyFile,omitempty" json:"keyFile,omitempty" xml:"keyFile,omitempty"` Port int `yaml:"port,omitempty" json:"port,omitempty" xml:"port,omitempty"` // DisableOptions 是否禁用自动生成 OPTIONS 和 HEAD 请求的处理 DisableOptions bool `yaml:"disableOptions,omitempty" json:"disableOptions,omitempty" xml:"disableOptions,omitempty"` DisableHead bool `yaml:"disableHead,omitempty" json:"disableHead,omitempty" xml:"disableHead,omitempty"` // Headers 附加的报头信息 // // 一些诸如跨域等报头信息,可以在此作设置。 // // 报头信息可能在其它处理器被修改。 Headers pairs `yaml:"headers,omitempty" json:"headers,omitempty" xml:"headers,omitempty"` // Static 静态内容,键名为 URL 路径,键值为文件地址 // // 比如在 Domain 和 Root 的值分别为 example.com 和 blog 时, // 将 Static 的值设置为 /admin ==> ~/data/assets/admin // 表示将 example.com/blog/admin/* 解析到 ~/data/assets/admin 目录之下。 Static pairs `yaml:"static,omitempty" json:"static,omitempty" xml:"static,omitempty"` // AllowedDomains 限定访问域名。 // // 若指定了此值,则只有此列表中指定的域名可以访问当前网页。 // 诸如 IP 和其它域名的指向将不再启作用。 // // 在 AllowedDomains 中至少存在一个及以上的域名时,Domain // 中指定的域名会自动合并到当前列表中。 // AllowedDomains 为空时,并不会限定域名为 Domain 指定的域名。 AllowedDomains []string `yaml:"allowedDomains,omitempty" json:"allowedDomains,omitempty" xml:"allowedDomains,omitempty"` // 应用于 http.Server 的几个变量。 ReadTimeout Duration `yaml:"readTimeout,omitempty" json:"readTimeout,omitempty" xml:"readTimeout,omitempty"` WriteTimeout Duration `yaml:"writeTimeout,omitempty" json:"writeTimeout,omitempty" xml:"writeTimeout,omitempty"` IdleTimeout Duration `yaml:"idleTiemout,omitempty" json:"idleTiemout,omitempty" xml:"idleTiemout,omitempty"` ReadHeaderTimeout Duration `yaml:"readHeaderTimeout,omitempty" json:"readHeaderTimeout,omitempty" xml:"readHeaderTimeout,omitempty"` MaxHeaderBytes int `yaml:"maxHeaderBytes,omitempty" json:"maxHeaderBytes,omitempty" xml:"maxHeaderBytes,omitempty"` // Compress 表示压缩的相关配置 // // 可以使用 * 作为结尾,同时指定多个,比如: // text/* 表示所有以 text/* 开头的 mime-type 类型。 Compress []string `yaml:"compress,omitempty" json:"compress,omitempty" xml:"compress,omitempty"` // URL 网站的根地址。 // 一般情况下,如果用到诸如生成 URL 地址什么的,会用到此值。 // // 若为空,则会根据配置文件的内容,生成网站首页地址。 // 若是 domain 为空,则生成的地址只有路径部分。 // // 用户也可台强制指定一个不同的地址,比如在被反向代理时, // 此值可能就和从 Domain、Port 等配置项自动生成的不一样。 URL string `yaml:"url,omitempty" json:"url,omitempty" xml:"url,omitempty"` URLPath string `yaml:"-" json:"-" xml:"-"` // URL 的 path 部分 // Timezone 时区名称,可以是 Asia/Shanghai 等,具体可参考: // https://en.wikipedia.org/wiki/List_of_tz_database_time_zones // // 为空和 Local(注意大小写) 值都会被初始化本地时间。 Timezone string `yaml:"timezone,omitempty" json:"timezone,omitempty" xml:"timezone,omitempty"` Location *time.Location `yaml:"-" json:"-" xml:"-"` }
WebConfig 项目的配置内容
Click to show internal directories.
Click to hide internal directories.