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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址