Open dezhishen opened 4 years ago
The generated doc allows you to use different settings. See example doc.go . Unfortunately, the gin-swagger middleware wasn't updated to support this.
@dezhiShen You could do something like this to create a middleware wrapping ginSwagger handler, retrieving the Host from os.Env or similar. Note that I'm using another approach, retrieving the Host from the request.
router.GET("/swagger/*any", func(context *gin.Context) {
docs.SwaggerInfo.Host = context.Request.Host
ginSwagger.WrapHandler(swaggerFiles.Handler)(context)
})
@dezhiShen You could do something like this to create a middleware wrapping ginSwagger handler, retrieving the Host from os.Env or similar. Note that I'm using another approach, retrieving the Host from the request.
router.GET("/swagger/*any", func(context *gin.Context) { docs.SwaggerInfo.Host = context.Request.Host ginSwagger.WrapHandler(swaggerFiles.Handler)(context) })
just reset the host before set router
docs.SwaggerInfo.Host = myconfigs.GetConfig().GetString("ginswagger.host")
@host
can't do that. Can I sethost
like seturl
?url := ginSwagger.URL(myConfig.GetString("ginswagger.url"))