Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/aaronvb/request_hole

Request Hole is a CLI tool and web UI that creates an endpoint to inspect HTTP requests or WebSocket connections and messages.
https://github.com/aaronvb/request_hole

cli endpoint go golang http logging requests tooling webhooks websocket

Last synced: 2 months ago
JSON representation

Request Hole is a CLI tool and web UI that creates an endpoint to inspect HTTP requests or WebSocket connections and messages.

Awesome Lists containing this project

README

        

# Request Hole CLI
[![go.dev Reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/aaronvb/request_hole)
[![Go Tests](https://github.com/aaronvb/request_hole/workflows/Test%20Go/badge.svg)](https://github.com/aaronvb/request_hole/actions/workflows/test_go.yml)
[![JS Tests](https://github.com/aaronvb/request_hole/workflows/Test%20JS/badge.svg)](https://github.com/aaronvb/request_hole/actions/workflows/test_js.yml)
[![Builds](https://github.com/aaronvb/request_hole/workflows/Builds/badge.svg)](https://github.com/aaronvb/request_hole/actions/workflows/builds.yml)

`rh` is a CLI tool for creating an ephemeral endpoint for testing and inspecting HTTP requests, WebSocket connections, and WebSocket messages from your application or webhook.

Request Hole CLI web ui

## Installation
### Homebrew
```
brew install aaronvb/request_hole/rh
```

### Clone repo and build
First make sure you have Go installed: https://golang.org/doc/install
```
git clone [email protected]:aaronvb/request_hole.git
cd request_hole
go build -o $GOBIN/rh
```
### Release versions
Download the release version for your system: https://github.com/aaronvb/request_hole/releases

## Usage
```
$ rh
```

```
rh: Request Hole
This CLI tool will let you create a temporary API endpoint for testing purposes.

Usage:
rh [command]

Available Commands:
help Help about any command
http Creates an http endpoint
version Print version number of Request Hole
ws Creates a websocket endpoint

Flags:
-a, --address string sets the address for the endpoint (default "localhost")
--details shows header details in the request
-h, --help help for rh
--log string writes incoming requests to the specified log file (example: --log rh.log)
-p, --port int sets the port for the endpoint (default 8080)
-r, --response_code int sets the response code (default 200)
--web runs the web UI to show incoming requests
--web_address string sets the address for the web UI (default "localhost")
--web_port int sets the port for the web UI (default 8081)

Use "rh [command] --help" for more information about a command.
```
## Using the Web UI
### Create an HTTP endpoint
```
$ rh http --web
```
This option will open a web UI that will display the incoming requests. Incoming requests will render live in the browser when they are received.

Request Hole CLI web ui

### Create a WebSocket endpoint
```
$ rh ws --web
```
This option will open a web UI that will display the WebSocket connections and incoming messages. Connections and incoming messages will render live in the browser when they are received.

Screen Shot 2021-11-05 at 15 03 31

## Using the CLI
### Creating an HTTP endpoint
To create an http endpoint with default settings (port 8080, return status code 200):
```
$ rh http
```
Request Hole CLI http

### Creating a WebSocket endpoint
To create a WebSocket endpoint with default settings (port 8080):
```
$ rh ws
```
Request Hole CLI WebSocket

### Show header details
This option shows all the header details in the incoming request.
```
$ rh http --details
```
Request Hole CLI details

### Log to file
This option will write the CLI output to the specified log file. Works with other options such as `--details`.
```
$ rh http --log rh.log
```
Request Hole CLI log

## Exposing Request Hole to the internet
Sometimes we need to expose `rh` to the internet to test applications or webhooks from outside of our local dev env. The best way to do this is to use a tunneling service such as [ngrok](https://ngrok.com).
```
$ ngrok http 3001
$ rh http -p 3001
```

## Running Tests and Building
It is recommended to run the JS build first so that the Go build can embed the latest web UI build.

### CLI
```
$ go test -v ./...
$ go build
```

### Web UI
```
$ cd web; yarn test
$ cd web; yarn build
```
#### For Development
```
$ cd web; yarn start
```
Visit `localhost:3000`

## Built With
- Go https://golang.org/
- logparams https://github.com/aaronvb/logparams
- logrequest https://github.com/aaronvb/logrequest
- cobra https://github.com/spf13/cobra
- gqlgen https://github.com/99designs/gqlgen (GraphQL/Websockets)
- gorilla/mux https://github.com/gorilla/mux
- Apollo https://github.com/apollographql/apollo-client (GraphQL frontend)
- create-react-app https://github.com/facebook/create-react-app
- Tailwind https://github.com/tailwindlabs/tailwindcss
- React Testing Library https://github.com/testing-library/react-testing-library