[add] cross domain env

This commit is contained in:
Max 2022-04-02 11:55:39 +08:00
parent bf0405d2c4
commit 098f1b53ce
2 changed files with 11 additions and 8 deletions

View file

@ -11,8 +11,9 @@ type Config struct {
Log string `json:"log,omitempty" env:"YAO_LOG"` // 服务日志地址
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
JWTSecret string `json:"jwt_secret,omitempty" env:"YAO_JWT_SECRET"` // JWT 密钥
DB DBConfig `json:"db,omitempty"` // 数据库配置
JWTSecret string `json:"jwt_secret,omitempty" env:"YAO_JWT_SECRET"` // JWT 密钥
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"`
}

View file

@ -19,9 +19,10 @@ func Start() {
gou.SetHTTPGuards(Guards)
gou.ServeHTTP(
gou.Server{
Host: config.Conf.Host,
Port: config.Conf.Port,
Root: "/api",
Host: config.Conf.Host,
Port: config.Conf.Port,
Root: "/api",
Allows: config.Conf.AllowFrom,
},
&shutdown, func(s gou.Server) {
shutdownComplete <- true
@ -35,9 +36,10 @@ func StartWithouttSession() {
gou.SetHTTPGuards(Guards)
gou.ServeHTTP(
gou.Server{
Host: config.Conf.Host,
Port: config.Conf.Port,
Root: "/api",
Host: config.Conf.Host,
Port: config.Conf.Port,
Root: "/api",
Allows: config.Conf.AllowFrom,
},
&shutdown, func(s gou.Server) {
shutdownComplete <- true