Explorar el Código

update

master
dengbiao hace 3 semanas
padre
commit
310ea699da
Se han modificado 1 ficheros con 11 adiciones y 5 borrados
  1. +11
    -5
      app/router/router.go

+ 11
- 5
app/router/router.go Ver fichero

@@ -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)



Cargando…
Cancelar
Guardar