package api

// @Time    : 2023/2/22 7:58 PM
// @Author  : lvhongmeng

import (
	"github.com/gin-gonic/gin"
	"github.com/tidbcloud/grpc-metadb/internal"
)

func Routers(ginEng *gin.Engine) {
	ginEng.Any(
		"/healthz", func(c *gin.Context) {
			c.Status(200)
		},
	)

	// Error
	routeError(ginEng)

	// Cors
	routeCors(ginEng)

	// Real REST-API registry
	routeRestAPI(ginEng)
}

func routeError(router *gin.Engine) {
	router.Use(APIErrorJSONReporter())
}

func routeCors(router *gin.Engine) {
	router.Use(Cors())
}

func routeRestAPI(router *gin.Engine) {
	dataAppsSqlEditor := router.Group("/api/v1/dataapps")
	{
		dataAppsSqlEditor.GET("/test", internal.Test)

	}

}
