38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package config
|
|
|
|
type Conf struct {
|
|
Server *ServerConfig `yaml:"server"`
|
|
Mysql *MysqlConfig `yaml:"mysql"`
|
|
}
|
|
|
|
type ServerConfig struct {
|
|
Addr string `yaml:"addr" comment:"监听 地址:端口"`
|
|
PreFork bool `yaml:"preFork" comment:"是否开启多进程"`
|
|
CaseSensitive bool `yaml:"caseSensitive" comment:"路由 大小写严格"`
|
|
// 严格路由 例: 设置为 true 时, /foo != /foo/
|
|
StrictRouting bool `yaml:"strictRouting" comment:"严格路由模式"`
|
|
// 设置 Http 请求头中的 Server 名称
|
|
ServerHeader string `yaml:"serverHeader" comment:"服务器名称"`
|
|
// 是否添加 /routes 路由 用于获取所有路由信息
|
|
EnableRoutesMsg bool `yaml:"enableRoutesMsg" comment:"启用路由信息 /routes"`
|
|
EnableSwag bool `yaml:"enableSwag" comment:"是否启用 swag 访问路径: /swagger"`
|
|
}
|
|
|
|
type MysqlConfig struct {
|
|
DataSources []string `yaml:"dataSources" comment:"数据源 参考 xorm 数据源配置"`
|
|
AutoSync bool `yaml:"autoSync" comment:"自动同步数据库/表结构"`
|
|
}
|
|
|
|
func DefaultConfig() *Conf {
|
|
return &Conf{
|
|
Server: &ServerConfig{
|
|
Addr: ":6573",
|
|
PreFork: true,
|
|
CaseSensitive: true,
|
|
StrictRouting: false,
|
|
ServerHeader: "SkServer",
|
|
EnableRoutesMsg: false,
|
|
},
|
|
}
|
|
}
|