加上自定义 webhooks

APIGit

2023-05-16

apigit-custom-webhooks

使用 Apigit 构建自定义 Webhook

在 Apigit,我们明白简化开发人员的生活至关重要。为此,我们有越来越多的常用集成列表,我们的自定义 webhook 允许开发人员通过触发操作来自定义他们的工作流程。通过这种方式,我们可以简单高效地访问必要的数据并自动化他们的工作流程。

什么是自定义 Webhook?

应用程序使用自定义 webhook(也称为 Web 回调)与其他应用程序连接,以获取有关更新或正在监视的事件的即时通知。但是,与定期提取数据的常规 API 调用不同,webhook 允许您获取实时更新。

前缀自定义 Webhooks

要为您的存储库创建 webhook,请单击存储库旁边的设置图标。 ️ apigit-custom-webhooks-add

要了解 webhook 的工作原理,请按照以下步骤操作:

  1. 使用 Apigit 发布模拟服务器。
  2. 填补Web Hook URL 带有模拟服务器 URL 的字段。
  3. 监视模拟服务器日志以了解在您的存储库中所做的任何更改。

这是我尝试发布问题时的日志。

Content-Type: application/json
host: service-432c52uwedzskn22
User-Agent: GogsServer
X-Amzn-Trace-Id: Root=1-646429f9-600198f81eac6574410074fe
X-Apigit-Delivery: 3fdcd42d-5bcb-45c5-b01a-27a2e5e23b00
X-Apigit-Event: issues
X-Apigit-Signature:
X-Forwarded-For: 54.203.224.187
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Github-Delivery: 3fdcd42d-5bcb-45c5-b01a-27a2e5e23b00
X-Github-Event: issues
X-My-Request-Header: XXX

{
  "action": "opened",
  "number": 5,
  "issue": {
    "id": 126,
    "number": 5,
    "user": {
      "id": 1346,
      "username": "xxxx",
      "login": "xxxx",
      "full_name": "",
      "email": "xx@xx.com",
      "avatar_url": "https://secure.gravatar.com/avatar/xx?d=identicon",
      "is_invite_pending": false
    },
    "title": "5",
    "body": "5",
    "labels": [],
    "milestone": null,
    "assignee": null,
    "state": "open",
    "comments": 0,
    "created_at": "0001-01-01T00:00:00Z",
    "updated_at": "0001-01-01T00:00:00Z",
    "pull_request": null
  },
  "repository": {
    "id": 1210,
    "owner": {
      "id": 1346,
      "username": "tuass",
      "login": "tuass",
      "full_name": "",
      "email": "xx@xx.com",
      "avatar_url": "https://secure.gravatar.com/avatar/xx?d=identicon",
      "is_invite_pending": false
    },
    "name": "test",
    "full_name": "xx/test",
    "description": "",
    "private": true,
    "unlisted": false,
    "fork": false,
    "parent": null,
    "empty": false,
    "mirror": false,
    "size": 876544,
    "html_url": "https://app.apigit.com/repository/xxxx/test",
    "ssh_url": "git@app.apigit.com:xxxx/test.git",
    "clone_url": "https://app.apigit.com/xxxx/test.git",
    "remote_addr": "",
    "website": "",
    "stars_count": 0,
    "forks_count": 0,
    "watchers_count": 1,
    "open_issues_count": 0,
    "default_branch": "master",
    "created_unix": "2023-04-29T03:36:18Z",
    "updated_unix": "2023-05-16T22:23:21Z",
    "status": 0
  },
  "sender": {
    "id": 1346,
    "username": "xxxx",
    "login": "xxxx",
    "full_name": "",
    "email": "xx@xx.com",
    "avatar_url": "https://secure.gravatar.com/avatar/xx?d=identicon",
    "is_invite_pending": false
  }
}