An open API service indexing awesome lists of open source software.

https://github.com/gugahoi/blackhole

Echo webserver to debug webhooks
https://github.com/gugahoi/blackhole

cli server webhooks

Last synced: about 1 month ago
JSON representation

Echo webserver to debug webhooks

Awesome Lists containing this project

README

          

# Blackhole

Blackhole is a CLI tool for debugging webhooks. It creates a local server that accepts all incoming HTTP/HTTPS requests, prints their details (headers, body, etc.) to the console with syntax highlighting, and always responds with a `200 OK`.

## Features

- **Catch-all**: Accepts any method (GET, POST, PUT, DELETE, etc.) and any path.
- **Visuals**: ANSI-colored logs for easy reading in the terminal.
- **JSON Support**: Automatically detects and pretty-prints JSON bodies.
- **HTTPS**:
- Automatic self-signed certificate generation (zero config).
- Support for custom certificates (e.g., via `mkcert`).

## Installation

### Prerequisites
- [Go](https://go.dev/) 1.16+ installed.

### Build
```bash
cd blackhole
go build -o blackhole
```

## Usage

### Basic HTTP
Listen on the default port (8080):
```bash
./blackhole
```

Listen on a custom port:
```bash
./blackhole -port 9000
```

### HTTPS

**Option 1: Automatic Self-Signed Certificate**
Quickest way to test HTTPS. Browsers and tools like `curl` will warn about the certificate being untrusted (use `curl -k` to ignore).
```bash
./blackhole -https
```

**Option 2: Trusted Certificate (e.g., with mkcert)**
If you need a "green lock" locally, use [mkcert](https://github.com/FiloSottile/mkcert) to generate valid certificates:
```bash
# Generate certs
mkcert localhost

# Run blackhole with them
./blackhole -cert localhost.pem -key localhost-key.pem
```

## Example Output

```text
--------------------------------------------------
[15:04:05] POST /webhook/v1 HTTP/1.1
Query Params:
id: 123
Headers:
Content-Type: application/json
User-Agent: Go-http-client/1.1
Body:
{
"event": "charge.succeeded",
"amount": 1000
}
```