Browse Source

update

master
dengbiao 1 month ago
parent
commit
310ea699da
1 changed files with 11 additions and 5 deletions
  1. +11
    -5
      app/router/router.go

+ 11
- 5
app/router/router.go View File

@@ -5,6 +5,7 @@ import (
"applet/app/hdl"
"applet/app/mw"
_ "applet/docs"
"fmt"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
@@ -32,13 +33,18 @@ func Init() *gin.Engine {
r.GET("/api/open/swagger/*any", gin.BasicAuth(gin.Accounts{
"jihuoniao": "123123",
}), func(c *gin.Context) {
//requestTls := "http://"
//if c.Request.TLS != nil {
// requestTls = "https://"
//}
requestTls := "http://"
if c.Request.TLS != nil {
requestTls = "https://"
}
r.Use(mw.SwagAuth())
r.Use(cors.Default())
ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.URL("http://584267.adcms.zhiyingos.cn/api/api-docs/open.json"))(c)
fmt.Println(requestTls + c.GetHeader("Real-Host") + "/api/api-docs/open.json")
if c.GetHeader("Real-Host") != "" {
ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.URL(requestTls+c.GetHeader("Real-Host")+"/api/api-docs/open.json"))(c)
} else {
ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.URL(requestTls+c.Request.Host+"/api/api-docs/open.json"))(c)
}
})
r.Use(mw.ChangeHeader)



Loading…
Cancel
Save