feat!: listen to both http & https (#4536)

Co-authored-by: Andy Hsu <i@nn.ci>
This commit is contained in:
BoYanZh
2023-06-10 22:26:09 +08:00
committed by Andy Hsu
parent 363e036bf0
commit f646d2a699
6 changed files with 79 additions and 29 deletions

View File

@ -20,9 +20,11 @@ type Database struct {
}
type Scheme struct {
Https bool `json:"https" env:"HTTPS"`
CertFile string `json:"cert_file" env:"CERT_FILE"`
KeyFile string `json:"key_file" env:"KEY_FILE"`
DisableHttp bool `json:"disable_http" env:"DISABLE_HTTP"`
Https bool `json:"https" env:"HTTPS"`
ForceHttps bool `json:"force_https" env:"FORCE_HTTPS"`
CertFile string `json:"cert_file" env:"CERT_FILE"`
KeyFile string `json:"key_file" env:"KEY_FILE"`
}
type LogConfig struct {
@ -38,6 +40,7 @@ type Config struct {
Force bool `json:"force" env:"FORCE"`
Address string `json:"address" env:"ADDR"`
Port int `json:"port" env:"PORT"`
HttpsPort int `json:"https_port" env:"HTTPS_PORT"`
SiteURL string `json:"site_url" env:"SITE_URL"`
Cdn string `json:"cdn" env:"CDN"`
JwtSecret string `json:"jwt_secret" env:"JWT_SECRET"`
@ -60,6 +63,7 @@ func DefaultConfig() *Config {
return &Config{
Address: "0.0.0.0",
Port: 5244,
HttpsPort: 5245,
JwtSecret: random.String(16),
TokenExpiresIn: 48,
TempDir: tempDir,