feat[Https]: added https support (#113)

This commit is contained in:
zhangwenjian
2020-06-11 23:56:05 +08:00
parent 5d69b32119
commit 0177fb17b7
9 changed files with 89 additions and 5 deletions
+21 -1
View File
@@ -11,6 +11,8 @@ type Application struct {
JwtSecret string
Mode string
DemoMsg string
Domain string
IsHttps bool
}
func InitApplication(cfg *viper.Viper) *Application {
@@ -18,12 +20,30 @@ func InitApplication(cfg *viper.Viper) *Application {
ReadTimeout: cfg.GetInt("readTimeout"),
WriterTimeout: cfg.GetInt("writerTimeout"),
Host: cfg.GetString("host"),
Port: cfg.GetString("port"),
Port: portDefault(cfg),
Name: cfg.GetString("name"),
JwtSecret: cfg.GetString("jwtSecret"),
Mode: cfg.GetString("mode"),
DemoMsg: cfg.GetString("demoMsg"),
Domain: cfg.GetString("domain"),
IsHttps: cfg.GetBool("ishttps"),
}
}
var ApplicationConfig = new(Application)
func portDefault(cfg *viper.Viper) string {
if cfg.GetString("port") == "" {
return "8000"
} else {
return cfg.GetString("port")
}
}
func isHttpsDefault(cfg *viper.Viper) bool {
if cfg.GetString("ishttps") == "" || cfg.GetBool("ishttps") == false{
return false
} else {
return true
}
}