https://github.com/bpazy/webhook-forwarder
Forward the webhook request
https://github.com/bpazy/webhook-forwarder
webhook webhook-forwarder webhook-relay
Last synced: 3 months ago
JSON representation
Forward the webhook request
- Host: GitHub
- URL: https://github.com/bpazy/webhook-forwarder
- Owner: Bpazy
- License: gpl-3.0
- Created: 2022-11-28T13:12:25.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-04T17:36:17.000Z (about 1 year ago)
- Last Synced: 2025-02-15T10:45:22.595Z (4 months ago)
- Topics: webhook, webhook-forwarder, webhook-relay
- Language: Go
- Homepage:
- Size: 67.4 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# webhook-forwarder
[](https://github.com/Bpazy/webhook-forwarder/actions/workflows/build.yml)
[](https://github.com/Bpazy/webhook-forwarder/actions/workflows/test.yml)
[](https://github.com/Bpazy/webhook-forwarder/actions/workflows/docker-publish.yml)
[](https://sonarcloud.io/dashboard?id=Bpazy_webhook-forwarder)
[](https://goreportcard.com/report/github.com/Bpazy/webhook-forwarder)Forward the webhook request.

## Usage
I suppose your webhook request body looks like this:
```json
{
"alerts": [
{
"status": "resolved",
"labels": {
"alertname": "325i alert"
}
}
]
}
```And your backend wanted:
```json
{
"body": "Test Bark Server",
"title": "bleem"
}
```Now you can use `webhook-forwarder` to receive and redirect and modify the webhook request like this:
```js
// ~/.config/webhook-forwarder/test.js
function convert(origin) {
alert = origin.alerts[0];
return {
target: ["https://api.day.app/asd/"],
payload: {
title: alert.labels.alertname,
body: "",
}
}
};
```Finally your backend will got correct body.
> Replace `:name` with the name of the file in the `templates` directory.```sh
curl -X POST http://localhost:8080/forward/:name -d '{"alerts":[{"status":"resolved","labels":{"alertname":"325i alert"}}]}'
```## Docker Deploy
```yaml
version: '3'
services:
webhook-forwarder:
image: ghcr.io/bpazy/webhook-forwarder:master
environment:
- PORT=:8080
restart: always
ports:
- "8080:8080"
volumes:
- /home/ubuntu/webhook-forwarder/templates:/root/.config/webhook-forwarder/templates
```