[add] cross domain env
This commit is contained in:
parent
bf0405d2c4
commit
098f1b53ce
2 changed files with 11 additions and 8 deletions
|
|
@ -11,8 +11,9 @@ type Config struct {
|
||||||
Log string `json:"log,omitempty" env:"YAO_LOG"` // 服务日志地址
|
Log string `json:"log,omitempty" env:"YAO_LOG"` // 服务日志地址
|
||||||
LogMode string `json:"log_mode,omitempty" env:"YAO_LOG_MODE" envDefault:"TEXT"` // 服务日志模式 JSON|TEXT
|
LogMode string `json:"log_mode,omitempty" env:"YAO_LOG_MODE" envDefault:"TEXT"` // 服务日志模式 JSON|TEXT
|
||||||
// Session string `json:"session,omitempty" env:"YAO_SESSION" envDefault:"memory"` // 用户会话模式 memory|redis|database
|
// Session string `json:"session,omitempty" env:"YAO_SESSION" envDefault:"memory"` // 用户会话模式 memory|redis|database
|
||||||
JWTSecret string `json:"jwt_secret,omitempty" env:"YAO_JWT_SECRET"` // JWT 密钥
|
JWTSecret string `json:"jwt_secret,omitempty" env:"YAO_JWT_SECRET"` // JWT 密钥
|
||||||
DB DBConfig `json:"db,omitempty"` // 数据库配置
|
DB DBConfig `json:"db,omitempty"` // 数据库配置
|
||||||
|
AllowFrom []string `json:"allowfrom,omitempty" envSeparator:"|" env:"YAO_ALLOW_FROM" ` // Domain list the separator is |
|
||||||
Session SessionConfig `json:"session,omitempty"`
|
Session SessionConfig `json:"session,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ func Start() {
|
||||||
gou.SetHTTPGuards(Guards)
|
gou.SetHTTPGuards(Guards)
|
||||||
gou.ServeHTTP(
|
gou.ServeHTTP(
|
||||||
gou.Server{
|
gou.Server{
|
||||||
Host: config.Conf.Host,
|
Host: config.Conf.Host,
|
||||||
Port: config.Conf.Port,
|
Port: config.Conf.Port,
|
||||||
Root: "/api",
|
Root: "/api",
|
||||||
|
Allows: config.Conf.AllowFrom,
|
||||||
},
|
},
|
||||||
&shutdown, func(s gou.Server) {
|
&shutdown, func(s gou.Server) {
|
||||||
shutdownComplete <- true
|
shutdownComplete <- true
|
||||||
|
|
@ -35,9 +36,10 @@ func StartWithouttSession() {
|
||||||
gou.SetHTTPGuards(Guards)
|
gou.SetHTTPGuards(Guards)
|
||||||
gou.ServeHTTP(
|
gou.ServeHTTP(
|
||||||
gou.Server{
|
gou.Server{
|
||||||
Host: config.Conf.Host,
|
Host: config.Conf.Host,
|
||||||
Port: config.Conf.Port,
|
Port: config.Conf.Port,
|
||||||
Root: "/api",
|
Root: "/api",
|
||||||
|
Allows: config.Conf.AllowFrom,
|
||||||
},
|
},
|
||||||
&shutdown, func(s gou.Server) {
|
&shutdown, func(s gou.Server) {
|
||||||
shutdownComplete <- true
|
shutdownComplete <- true
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue