chore: 拆分 router (part I)

This commit is contained in:
Liam Chan 2024-08-22 09:50:52 +08:00
parent 23218acc18
commit 7047d896f8
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package handler
import (
"github.com/gin-gonic/gin"
"net/http"
)
func GetConnections(c *gin.Context) {
// 这里可以添加获取产品的逻辑
c.JSON(http.StatusOK, gin.H{"message": "Get Connections"})
}
func CreateConnection(c *gin.Context) {
// 这里可以添加创建产品的逻辑
c.JSON(http.StatusCreated, gin.H{"message": "Connection Created"})
}

18
router/router.go Normal file
View File

@ -0,0 +1,18 @@
package router
import (
"github.com/gin-gonic/gin"
"onvif-agent/router/handler"
)
func SetupRoutes(r *gin.Engine) {
// ONVIF 相关路由
userGroup := r.Group("/onvif")
{
connectionGroup := userGroup.Group("/connections")
{
connectionGroup.GET("/", handler.GetConnections)
connectionGroup.POST("/", handler.CreateConnection)
}
}
}