feat!: support listen to the unix (close #4671)

Starting from this commit, the HTTP server related config all move to the scheme
This commit is contained in:
Andy Hsu
2023-07-04 17:56:02 +08:00
parent 59dbf4496f
commit 7d20a01dba
4 changed files with 53 additions and 24 deletions

View File

@ -12,7 +12,7 @@ func ForceHttps(c *gin.Context) {
if c.Request.TLS == nil {
host := c.Request.Host
// change port to https port
host = strings.Replace(host, fmt.Sprintf(":%d", conf.Conf.Port), fmt.Sprintf(":%d", conf.Conf.HttpsPort), 1)
host = strings.Replace(host, fmt.Sprintf(":%d", conf.Conf.Scheme.HttpPort), fmt.Sprintf(":%d", conf.Conf.Scheme.HttpsPort), 1)
c.Redirect(302, "https://"+host+c.Request.RequestURI)
c.Abort()
return