{"id":15055406,"url":"https://github.com/flc1125/go-gitlab-webhook","last_synced_at":"2026-05-02T17:00:47.728Z","repository":{"id":253875544,"uuid":"844501981","full_name":"flc1125/go-gitlab-webhook","owner":"flc1125","description":" 🚀 A lightweight Gitlab webhook dispatcher for efficient event handling","archived":false,"fork":false,"pushed_at":"2026-05-02T15:04:20.000Z","size":595,"stargazers_count":6,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"3.x","last_synced_at":"2026-05-02T16:27:36.350Z","etag":null,"topics":["dispatcher","event","gitlab","golang","webhook"],"latest_commit_sha":null,"homepage":"https://github.com/flc1125/go-gitlab-webhook","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flc1125.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-19T11:48:50.000Z","updated_at":"2026-05-02T15:03:37.000Z","dependencies_parsed_at":"2025-12-15T22:10:04.503Z","dependency_job_id":"4644d8f5-eec7-4f4b-bbc9-8160d2f51bec","html_url":"https://github.com/flc1125/go-gitlab-webhook","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.4545454545454546,"last_synced_commit":"5c284065630135a9fb9b9b161448e1a474244f2c"},"previous_names":["flc1125/go-gitlab-webhook"],"tags_count":42,"template":false,"template_full_name":null,"purl":"pkg:github/flc1125/go-gitlab-webhook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flc1125%2Fgo-gitlab-webhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flc1125%2Fgo-gitlab-webhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flc1125%2Fgo-gitlab-webhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flc1125%2Fgo-gitlab-webhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flc1125","download_url":"https://codeload.github.com/flc1125/go-gitlab-webhook/tar.gz/refs/heads/3.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flc1125%2Fgo-gitlab-webhook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32542201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T12:25:33.646Z","status":"ssl_error","status_checked_at":"2026-05-02T12:24:51.733Z","response_time":132,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dispatcher","event","gitlab","golang","webhook"],"created_at":"2024-09-24T21:41:50.919Z","updated_at":"2026-05-02T17:00:47.713Z","avatar_url":"https://github.com/flc1125.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gitlab Webhook Dispatcher 🚀\n\n![Supported Go Versions](https://img.shields.io/badge/Go-%3E%3D1.25.0-blue)\n[![Package Version](https://badgen.net/github/release/flc1125/go-gitlab-webhook/stable)](https://github.com/flc1125/go-gitlab-webhook/releases)\n[![GoDoc](https://pkg.go.dev/badge/github.com/flc1125/go-gitlab-webhook/v3)](https://pkg.go.dev/github.com/flc1125/go-gitlab-webhook/v3)\n[![codecov](https://codecov.io/gh/flc1125/go-gitlab-webhook/graph/badge.svg?token=QPTHZ5L9GT)](https://codecov.io/gh/flc1125/go-gitlab-webhook)\n[![Go Report Card](https://goreportcard.com/badge/github.com/flc1125/go-gitlab-webhook)](https://goreportcard.com/report/github.com/flc1125/go-gitlab-webhook)\n[![CI](https://github.com/flc1125/go-gitlab-webhook/actions/workflows/ci.yml/badge.svg)](https://github.com/flc1125/go-gitlab-webhook/actions/workflows/ci.yml)\n[![tests](https://github.com/flc1125/go-gitlab-webhook/actions/workflows/test.yml/badge.svg)](https://github.com/flc1125/go-gitlab-webhook/actions/workflows/test.yml)\n[![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)\n\nThis is a simple webhook dispatcher for Gitlab. It listens for incoming webhooks and dispatches them to the appropriate handler.\n\n## ✨ Features\n\n- 📋 Very convenient registration of listeners\n- 🔄 A single listener can implement multiple different webhook functions\n- ⚡ Support asynchronous and efficient processing\n- 🚀 Multiple dispatch methods\n- 🔐 Token validation support for secure webhook handling\n\n## 📦 Installation\n\n```shell\ngo get github.com/flc1125/go-gitlab-webhook/v3\n```\n\n## 🔗 Compatibility\n\n| go-gitlab-webhook | GitLab Go Client |\n| --- | --- |\n| `1.x` | [xanzy/go-gitlab](https://github.com/xanzy/go-gitlab) |\n| `2.x` | [gitlab-org/api/client-go](https://gitlab.com/gitlab-org/api/client-go) |\n| `3.x` | [gitlab-org/api/client-go/v2](https://gitlab.com/gitlab-org/api/client-go/v2) |\n\n## 💻 Usage\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/flc1125/go-gitlab-webhook/v3\"\n\t\"gitlab.com/gitlab-org/api/client-go/v2\"\n)\n\nvar (\n\t_ gitlabwebhook.BuildListener         = (*testBuildListener)(nil)\n\t_ gitlabwebhook.CommitCommentListener = (*testCommitCommentListener)(nil)\n\t_ gitlabwebhook.BuildListener         = (*testBuildAndCommitCommentListener)(nil)\n\t_ gitlabwebhook.CommitCommentListener = (*testBuildAndCommitCommentListener)(nil)\n)\n\ntype testBuildListener struct{}\n\nfunc (l *testBuildListener) OnBuild(ctx context.Context, event *gitlab.BuildEvent) error {\n\t// do something\n\treturn nil\n}\n\ntype testCommitCommentListener struct{}\n\nfunc (l *testCommitCommentListener) OnCommitComment(ctx context.Context, event *gitlab.CommitCommentEvent) error {\n\t// do something\n\treturn nil\n}\n\ntype testBuildAndCommitCommentListener struct{}\n\nfunc (l *testBuildAndCommitCommentListener) OnBuild(ctx context.Context, event *gitlab.BuildEvent) error {\n\t// do something\n\treturn nil\n}\n\nfunc (l *testBuildAndCommitCommentListener) OnCommitComment(ctx context.Context, event *gitlab.CommitCommentEvent) error {\n\t// do something\n\treturn nil\n}\n\nfunc main() {\n\tdispatcher := gitlabwebhook.NewDispatcher(\n\t\tgitlabwebhook.RegisterListeners(\n\t\t\t\u0026testBuildListener{},\n\t\t\t\u0026testCommitCommentListener{},\n\t\t\t\u0026testBuildAndCommitCommentListener{},\n\t\t),\n\t\tgitlabwebhook.WithMiddlewares(\n\t\t\tloggingMiddleware,\n\t\t\t// Only runs for push events.\n\t\t\tgitlabwebhook.MiddlewareForEvent(func(ctx context.Context, event *gitlab.PushEvent) error {\n\t\t\t\tlog.Printf(\"push event: %s\", event.Project.PathWithNamespace)\n\t\t\t\treturn nil\n\t\t\t}),\n\t\t),\n\t)\n\n\tdispatcher.RegisterListeners(\n\t\t\u0026testBuildListener{},\n\t\t\u0026testCommitCommentListener{},\n\t\t\u0026testBuildAndCommitCommentListener{},\n\t)\n\n\thttp.Handle(\"/webhook\", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tif err := dispatcher.DispatchRequest(r,\n\t\t\tgitlabwebhook.DispatchRequestWithToken(\"your-secret-token\"), // validate token, if needed\n\t\t\tgitlabwebhook.DispatchRequestWithContext(context.Background()), // custom context\n\t\t\tgitlabwebhook.DispatchRequestWithMaxBodyBytes(10\u003c\u003c20), // limit payload size to 10 MiB\n\t\t); err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tw.WriteHeader(http.StatusNoContent)\n\t}))\n\n\tif err := http.ListenAndServe(\":8080\", nil); err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc loggingMiddleware(next gitlabwebhook.HandlerFunc) gitlabwebhook.HandlerFunc {\n\treturn func(ctx context.Context, event any) error {\n\t\tlog.Printf(\"received webhook event: %T\", event)\n\t\treturn next(ctx, event)\n\t}\n}\n```\n\n## 🔐 Security Notes\n\nIf your webhook endpoint is exposed publicly, limit request body size before parsing payloads. You can use `DispatchRequestWithMaxBodyBytes` when calling `DispatchRequest`, or enforce an equivalent limit in your HTTP server or reverse proxy.\n\n## 📜 License\n\nMIT License. See [LICENSE](LICENSE) for the full license text.\n\n## 💖 Thanks\n\n- [gitlab-org/api/client-go](https://gitlab.com/gitlab-org/api/client-go)(Formerly known as: [xanzy/go-gitlab](https://github.com/xanzy/go-gitlab)): Go library for accessing the GitLab API\n- [stretchr/testify](github.com/stretchr/testify): A toolkit with common assertions and mocks that plays nicely with the standard library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflc1125%2Fgo-gitlab-webhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflc1125%2Fgo-gitlab-webhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflc1125%2Fgo-gitlab-webhook/lists"}