加上自定義 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
  }
}