// Copyright 2019 getensh.com. All rights reserved. // Use of this source code is governed by getensh.com. package route import ( "net/http" "github.com/gin-gonic/gin" v1_0 "adm-data-gateway/controller/v1.0" _ "adm-data-gateway/docs" "adm-data-gateway/route/middware" ) func SetupRoute(engine *gin.Engine) { // 404页面 engine.NoRoute(func(c *gin.Context) { c.String(http.StatusNotFound, "Not Found") }) // 服务健康检查 engine.GET("/ping", func(c *gin.Context) { c.String(http.StatusOK, "pong") }) // version 1 apiv1_0 := engine.Group("/api/v1.0") { c := v1_0.NewController() apiv1_0.Use(middware.Cors(), middware.Sign(), middware.Verify()) query := apiv1_0.Group("/query") { query.OPTIONS("/", func(ctx *gin.Context) { ctx.AbortWithStatus(http.StatusNoContent) return }) query.POST("/", c.Query) } } }