webhook-forwarder

command module
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

README

webhook-forwarder

Build Test Docker Quality Gate Status Go Report Card

Forward the webhook request.

webhook-forwarder (2)

Usage

I suppose your webhook request body looks like this:

{
  "alerts": [
    {
      "status": "resolved",
      "labels": {
        "alertname": "325i alert"
      }
    }
  ]
}

And your backend wanted:

{
  "body": "Test Bark Server",
  "title": "bleem"
}

Now you can use webhook-forwarder to receive and redirect and modify the webhook request like this:

// ~/.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.

curl -X POST http://localhost:8080/forward/:name -d '{"alerts":[{"status":"resolved","labels":{"alertname":"325i alert"}}]}'

Docker Deploy

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

Documentation

Overview

Copyright © 2022 Bpazy

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳