go-hooks-server

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 8 Imported by: 0

README

Go Hooks Server

example workflow

Simple hooks server written in Go with native http package.

Installation
Local machine

Make sure you have Docker installed and then execute the following command:

docker-compose up

The server will automatically listen on port 9876.

Examples

The hooks server has 2 endpoints available.

POST /api/webhooks

This endpoint allows to register a webhook with urland token params provided.

Example cURL code snippet:

curl --location --request POST 'http://localhost:9876/api/webhooks' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url": "https://api.myserver.com/hooks",
    "token": "tok123"
}'

Example response:

{
  "id": "Qf2gRHt",
  "url": "https://api.myserver.com/hooks",
  "token": "tok123"
}
POST /api/webhooks/test

This endpoint is mainly used for testing hooks that were registered before.

X-WebhookId header is required.

Example cURL code snippet:

curl --location --request POST 'http://localhost:9876/api/webhooks/test' \
--header 'X-WebhookId: Qf2gRHt' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payload": [{"user": "test"}]
}'
Documentation

Go Reference

Limitations
  • The hooks server is using in-memory store which will be reset on server restart.
  • Request timeout is missing for /api/webhooks/testendpoint meaning that requests to unknown/un-existing domains may take longer time to finish. This can be fixed by providing standalone HTTP client with http.Transport implementation.
  • Rate-limiting is not supported at the moment.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL