[message pusher] - add swagger
This commit is contained in:
@@ -2,12 +2,41 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"io.wdd.message_pusher/docs"
|
||||
"io.wdd.message_pusher/router"
|
||||
)
|
||||
import "github.com/swaggo/gin-swagger" // gin-swagger middleware
|
||||
import "github.com/swaggo/files" // swagger embed files
|
||||
|
||||
// @title Swagger Example API
|
||||
// @version 1.0
|
||||
// @description This is a sample server celler server.
|
||||
// @termsOfService http://swagger.io/terms/
|
||||
|
||||
// @contact.name API Support
|
||||
// @contact.url http://www.swagger.io/support
|
||||
// @contact.email support@swagger.io
|
||||
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
// @host localhost:8080
|
||||
// @BasePath
|
||||
|
||||
// @securityDefinitions.basic BasicAuth
|
||||
|
||||
// @externalDocs.description OpenAPI
|
||||
// @externalDocs.url https://swagger.io/resources/open-api/
|
||||
func main() {
|
||||
|
||||
engine := gin.Default()
|
||||
// programmatically set swagger info
|
||||
docs.SwaggerInfo.Title = "Wdd Message Pusher"
|
||||
docs.SwaggerInfo.Description = "Wdd Message Pusher Service"
|
||||
docs.SwaggerInfo.Version = "1.0"
|
||||
docs.SwaggerInfo.Host = "localhost:8080"
|
||||
docs.SwaggerInfo.BasePath = ""
|
||||
docs.SwaggerInfo.Schemes = []string{"http"}
|
||||
|
||||
// 强制日志颜色化
|
||||
gin.ForceConsoleColor()
|
||||
@@ -18,6 +47,7 @@ func main() {
|
||||
router.OctopusRouter(engine)
|
||||
}
|
||||
|
||||
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
err := engine.Run(":8080")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
Reference in New Issue
Block a user