diff --git a/config/config.go b/config/config.go index 3a27dd0..bf9e30f 100644 --- a/config/config.go +++ b/config/config.go @@ -19,7 +19,7 @@ type ServerConfig struct { Port int `toml:"port"` Host string `toml:"host"` SizeLimit int `toml:"sizeLimit"` - EnableH2C bool `toml:"enableH2C"` + EnableH2C string `toml:"enableH2C"` } type PagesConfig struct { diff --git a/config/config.toml b/config/config.toml index d06ce47..ce83e2a 100644 --- a/config/config.toml +++ b/config/config.toml @@ -2,7 +2,7 @@ host = "127.0.0.1" port = 8080 sizeLimit = 125 # MB -enableH2C = true +enableH2C = "on" # "on" or "off" [pages] enabled = false diff --git a/main.go b/main.go index 3fd40e6..3297f91 100644 --- a/main.go +++ b/main.go @@ -91,9 +91,19 @@ func init() { gin.SetMode(gin.ReleaseMode) router = gin.Default() - if cfg.Server.EnableH2C { + //H2C默认值为true,而后遵循cfg.Server.EnableH2C的设置 + if cfg.Server.EnableH2C == "on" { router.UseH2C = true + } else if cfg.Server.EnableH2C == "" { + router.UseH2C = true + } else { + router.UseH2C = false } + /*if !cfg.Server.EnableH2C { + router.UseH2C = false + } else { + router.UseH2C = true + }*/ setupApi(cfg, router, version)