2023-02-26 02:50:56 +08:00
|
|
|
package config
|
|
|
|
|
2023-02-26 21:10:43 +08:00
|
|
|
import (
|
2023-02-26 21:20:11 +08:00
|
|
|
"matrix-middle-service/pkg/database/driver/mysql/conf"
|
2023-02-26 21:10:43 +08:00
|
|
|
)
|
|
|
|
|
2023-02-26 02:50:56 +08:00
|
|
|
type Conf struct {
|
2023-02-26 21:10:43 +08:00
|
|
|
Server *ServerConfig `yaml:"server"`
|
|
|
|
DataSources []interface{} `yaml:"mysql"`
|
2023-02-26 02:50:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func DefaultConfig() *Conf {
|
|
|
|
return &Conf{
|
|
|
|
Server: &ServerConfig{
|
|
|
|
Addr: ":6573",
|
|
|
|
PreFork: true,
|
|
|
|
CaseSensitive: true,
|
|
|
|
StrictRouting: false,
|
|
|
|
ServerHeader: "SkServer",
|
|
|
|
EnableRoutesMsg: false,
|
|
|
|
},
|
2023-02-26 21:10:43 +08:00
|
|
|
DataSources: []interface{}{
|
|
|
|
DataSourcesType[any]{
|
|
|
|
Type: "mysql",
|
|
|
|
Config: conf.NewMysqlConfig([]string{
|
|
|
|
"root:12341234@tcp(127.0.0.1:3306)/db?charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai",
|
|
|
|
}, true),
|
|
|
|
},
|
|
|
|
},
|
2023-02-26 02:50:56 +08:00
|
|
|
}
|
|
|
|
}
|