HomeNav/cmd/APP/main.go

40 lines
810 B
Go
Raw Normal View History

2023-12-13 14:51:04 +08:00
package main
import (
2023-12-13 17:42:38 +08:00
"fmt"
2023-12-13 14:51:04 +08:00
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
router := gin.Default()
// 设置 webhook 路由
router.POST("/webhook", func(c *gin.Context) {
var json map[string]interface{}
// 将请求的 JSON 绑定到 json 变量
if err := c.BindJSON(&json); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// 处理 webhook 数据
// 在这里,我们只是简单地打印出接收到的数据
2023-12-13 17:42:38 +08:00
//println("Received webhook:", len(json))
2023-12-13 14:51:04 +08:00
2023-12-13 17:42:38 +08:00
fmt.Printf("q: %v\n", json)
c.String(http.StatusBadRequest, "success")
})
router.GET("/q", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"sss": "sss",
})
println("123")
2023-12-13 14:51:04 +08:00
})
// 启动服务器
router.Run(":8888") // 监听并在 0.0.0.0:8080 上启动服务
}