44 lines
918 B
Go
44 lines
918 B
Go
package main
|
|
|
|
import (
|
|
"HomeNav/middleware"
|
|
"fmt"
|
|
"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 数据
|
|
// 在这里,我们只是简单地打印出接收到的数据
|
|
//println("Received webhook:", len(json))
|
|
|
|
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",
|
|
//})
|
|
middleware.Hello()
|
|
// 输出html H1标签
|
|
c.String(http.StatusOK, "<h1>hello world</h1>")
|
|
|
|
})
|
|
|
|
// 启动服务器
|
|
router.Run(":8888") // 监听并在 0.0.0.0:8080 上启动服务
|
|
}
|