优化通知接口

This commit is contained in:
白茶清欢 2021-11-12 11:43:40 +08:00
parent b7af0f63ac
commit df6c263ea0
3 changed files with 9 additions and 6 deletions

View File

@ -8,8 +8,6 @@
package main package main
import ( import (
"encoding/json"
"fmt"
"git.zhangdeman.cn/zhangdeman/gopkg/git_hook" "git.zhangdeman.cn/zhangdeman/gopkg/git_hook"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -17,9 +15,12 @@ import (
func main() { func main() {
router := gin.Default() router := gin.Default()
// 注册回调路由 // 注册回调路由
_ = git_hook.RegisterGitHookRouter(router, func(ctx *gin.Context, hookData *git_hook.HookData) { _ = git_hook.RegisterGitHookRouter(router, func(ctx *gin.Context, hookData *git_hook.HookData) *git_hook.ResponseData {
callbackData, _ := json.Marshal(hookData) return &git_hook.ResponseData{
fmt.Println("回调数据 : ", string(callbackData)) Code: 0,
Message: "成功接收到web hook通知",
Data: hookData,
}
}) })
_ = router.Run(":12590") _ = router.Run(":12590")
} }

2
go.mod
View File

@ -3,7 +3,7 @@ module git.zhangdeman.cn/zhangdeman/git_hook
go 1.17 go 1.17
require ( require (
git.zhangdeman.cn/zhangdeman/gopkg v0.0.0-20211111140656-6287bc062fd8 git.zhangdeman.cn/zhangdeman/gopkg v0.0.0-20211112034039-2c436b1a6c2f
github.com/gin-gonic/gin v1.7.4 github.com/gin-gonic/gin v1.7.4
) )

2
go.sum
View File

@ -1,5 +1,7 @@
git.zhangdeman.cn/zhangdeman/gopkg v0.0.0-20211111140656-6287bc062fd8 h1:8Q8gDw9KrO2RkernimnXD8lPAu63YS2bwuMBK5nfI2o= git.zhangdeman.cn/zhangdeman/gopkg v0.0.0-20211111140656-6287bc062fd8 h1:8Q8gDw9KrO2RkernimnXD8lPAu63YS2bwuMBK5nfI2o=
git.zhangdeman.cn/zhangdeman/gopkg v0.0.0-20211111140656-6287bc062fd8/go.mod h1:+ga94Zdtpve/XVHlc3UbnrxXoNw9HCuGRowxtJsePag= git.zhangdeman.cn/zhangdeman/gopkg v0.0.0-20211111140656-6287bc062fd8/go.mod h1:+ga94Zdtpve/XVHlc3UbnrxXoNw9HCuGRowxtJsePag=
git.zhangdeman.cn/zhangdeman/gopkg v0.0.0-20211112034039-2c436b1a6c2f h1:KOJxfoNlRTaNRHa0yUT5rW08Ol2gZJmsnhm1w9YsTq4=
git.zhangdeman.cn/zhangdeman/gopkg v0.0.0-20211112034039-2c436b1a6c2f/go.mod h1:+ga94Zdtpve/XVHlc3UbnrxXoNw9HCuGRowxtJsePag=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=