39 lines
891 B
Go
39 lines
891 B
Go
package routes
|
|
|
|
import (
|
|
"cmii-uav-watchdog/controllers"
|
|
"cmii-uav-watchdog/middleware"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// SetupRouter 设置路由
|
|
func SetupRouter() *gin.Engine {
|
|
r := gin.Default()
|
|
|
|
// 注册中间件
|
|
r.Use(middleware.CORSMiddleware())
|
|
|
|
// API分组
|
|
api := r.Group("/api")
|
|
{
|
|
// 授权相关路由
|
|
auth := api.Group("/authorization")
|
|
{
|
|
authController := controllers.NewAuthController()
|
|
auth.POST("/generate", authController.GenerateAuthFile) // 授权文件生成
|
|
auth.POST("/code", authController.ReceiveAuthCode) // 授权码接收
|
|
auth.POST("/notify", authController.NotifyAuthInfo) // 授权信息通知
|
|
}
|
|
|
|
// 心跳检测路由
|
|
heartbeat := api.Group("/heartbeat")
|
|
{
|
|
heartbeatController := controllers.NewHeartbeatController()
|
|
heartbeat.POST("", heartbeatController.HandleHeartbeat) // 心跳检测
|
|
}
|
|
}
|
|
|
|
return r
|
|
}
|