Documentation
¶
Overview ¶
Package config 提供了从配置文件初始化 Server 的方法
Index ¶
- Constants
- func LoadJSON(f fs.FS, path string, v interface{}) error
- func LoadXML(f fs.FS, path string, v interface{}) error
- func LoadYAML(f fs.FS, path string, v interface{}) error
- func NewServer(name, version string, f fs.FS, b content.BuildResultFunc) (*server.Server, error)
- type Cache
- type Certificate
- type Duration
- type Error
- type HTTP
- type LetsEncrypt
- type Webconfig
Constants ¶
View Source
const ( LogsFilename = "logs.xml" WebFilename = "web.yaml" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶ added in v0.39.0
type Cache struct {
// 表示缓存的方式
//
// 目前支持以下几种试:
// - memory 以内存作为缓存;
// - memcached 以 memcached 作为缓存;
// - redis 以 redis 作为缓存;
// - file 以文件作为缓存;
Type string `yaml:"type" json:"type" xml:"type,attr"`
// 表示连接缓存服务器的参数
//
// - memory,此值为 time.Duration 格式的参数,用于表示执行回收的间隔;
// - memcached,则为服务器列表,多个服务器,以分号作为分隔;
// - redis,则为符合 Redis URI scheme 的字符串,可参考 https://www.iana.org/assignments/uri-schemes/prov/redis;
// - file,表示以半有分号分隔的参数列表,可以指定以下两个参数:
// - path 文件路径;
// - gc 执行回收的间隔,time.Duration 格式;
DSN string `yaml:"dsn" json:"dsn" xml:"dsn"`
}
Cache 缓存的相关配置
type Certificate ¶ added in v0.34.0
type Certificate struct {
Cert string `yaml:"cert,omitempty" json:"cert,omitempty" xml:"cert,omitempty"`
Key string `yaml:"key,omitempty" json:"key,omitempty" xml:"key,omitempty"`
}
Certificate 证书管理
type Duration ¶ added in v0.34.0
Duration 封装 time.Duration 以实现对 JSON、XML 和 YAML 的解析
func (Duration) MarshalText ¶ added in v0.39.0
MarshalText encoding.TextMarshaler 接口
func (*Duration) UnmarshalText ¶ added in v0.39.0
UnmarshalText encoding.TextUnmarshaler 接口
type Error ¶ added in v0.21.0
type Error struct {
Config, Field, Message string
Value interface{}
}
Error 表示配置内容字段错误
type HTTP ¶ added in v0.34.0
type HTTP struct {
// 网站的域名证书
//
// 不能同时与 LetsEncrypt 生效
Certificates []*Certificate `yaml:"certificates,omitempty" json:"certificates,omitempty" xml:"certificates,omitempty"`
// 配置 Let's Encrypt 证书
//
// 不能同时与 Certificates 生效
LetsEncrypt *LetsEncrypt `yaml:"letsEncrypt,omitempty" json:"letsEncrypt,omitempty" xml:"letsEncrypt,omitempty"`
// 应用于 http.Server 的几个变量
ReadTimeout Duration `yaml:"readTimeout,omitempty" json:"readTimeout,omitempty" xml:"readTimeout,attr,omitempty"`
WriteTimeout Duration `yaml:"writeTimeout,omitempty" json:"writeTimeout,omitempty" xml:"writeTimeout,attr,omitempty"`
IdleTimeout Duration `yaml:"idleTimeout,omitempty" json:"idleTimeout,omitempty" xml:"idleTimeout,attr,omitempty"`
ReadHeaderTimeout Duration `yaml:"readHeaderTimeout,omitempty" json:"readHeaderTimeout,omitempty" xml:"readHeaderTimeout,attr,omitempty"`
MaxHeaderBytes int `yaml:"maxHeaderBytes,omitempty" json:"maxHeaderBytes,omitempty" xml:"maxHeaderBytes,attr,omitempty"`
// contains filtered or unexported fields
}
HTTP 与 http 请求相关的设置
type LetsEncrypt ¶ added in v0.39.0
type LetsEncrypt struct {
Domains []string `yaml:"domains" json:"domains" xml:"domains"`
Cache string `yaml:"cache" json:"cache" xml:"cache"`
Email string `yaml:"email,omitempty" json:"email,omitempty" xml:"email,omitempty"`
ForceRSA bool `yaml:"forceRSA,omitempty" json:"forceRSA,omitempty" xml:"forceRSA,attr,omitempty"`
// 定义提早几天开始续订,如果为 0 表示提早 30 天。
RenewBefore uint `yaml:"renewBefore,omitempty" json:"renewBefore,omitempty" xml:"renewBefore,attr,omitempty"`
}
LetsEncrypt Let's Encrypt 的相关设置
type Webconfig ¶ added in v0.39.0
type Webconfig struct {
XMLName struct{} `yaml:"-" json:"-" xml:"web"`
// 网站端口
//
// 格式与 net/http.Server.Addr 相同
Port string `yaml:"port,omitempty" json:"port,omitempty" xml:"port,attr,omitempty"`
// 是否禁用自动生成 HEAD 请求
DisableHead bool `yaml:"disableHead,omitempty" json:"disableHead,omitempty" xml:"disableHead,attr,omitempty"`
// 与 HTTP 请求相关的设置项
HTTP *HTTP `yaml:"http,omitempty" json:"http,omitempty" xml:"http,omitempty"`
// 指定插件的搜索方式
//
// 通过 glob 语法搜索插件,比如:
// ~/plugins/*.so
// 具体可参考:https://golang.org/pkg/path/filepath/#Glob
// 为空表示没有插件。
//
// 当前仅支持部分系统,具体可查看:https://golang.org/pkg/plugin/
Plugins string `yaml:"plugins,omitempty" json:"plugins,omitempty" xml:"plugins,omitempty"`
// 时区名称
//
// 可以是 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"`
// 指定缓存对象
//
// 如果为空,则会采用内存作为缓存对象。
Cache *Cache `yaml:"cache,omitempty" json:"cache,omitempty" xml:"cache,omitempty"`
// 此处列出的类型将不会被压缩
//
// 可以带 *,比如 text/* 表示所有 mime-type 为 text/ 开始的类型。
IgnoreCompressTypes []string `yaml:"ignoreCompressTypes,omitempty" json:"ignoreCompressTypes,omitempty" xml:"ignoreCompressTypes,omitempty"`
// contains filtered or unexported fields
}
Webconfig 配置内容
Click to show internal directories.
Click to hide internal directories.