From df6c263ea0eddae89750aa18be9155ded7eb8283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 12 Nov 2021 11:43:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=9A=E7=9F=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- git_hook.go | 11 ++++++----- go.mod | 2 +- go.sum | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/git_hook.go b/git_hook.go index dd69de7..2133302 100644 --- a/git_hook.go +++ b/git_hook.go @@ -8,8 +8,6 @@ package main import ( - "encoding/json" - "fmt" "git.zhangdeman.cn/zhangdeman/gopkg/git_hook" "github.com/gin-gonic/gin" ) @@ -17,9 +15,12 @@ import ( func main() { router := gin.Default() // 注册回调路由 - _ = git_hook.RegisterGitHookRouter(router, func(ctx *gin.Context, hookData *git_hook.HookData) { - callbackData, _ := json.Marshal(hookData) - fmt.Println("回调数据 : ", string(callbackData)) + _ = git_hook.RegisterGitHookRouter(router, func(ctx *gin.Context, hookData *git_hook.HookData) *git_hook.ResponseData { + return &git_hook.ResponseData{ + Code: 0, + Message: "成功接收到web hook通知", + Data: hookData, + } }) _ = router.Run(":12590") } diff --git a/go.mod b/go.mod index 1ef9fcd..dfcda60 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.zhangdeman.cn/zhangdeman/git_hook go 1.17 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 ) diff --git a/go.sum b/go.sum index ca4a3c3..f556c89 100644 --- a/go.sum +++ b/go.sum @@ -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/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.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=