request_hole

command module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: MIT Imports: 5 Imported by: 0

README

Request Hole CLI

go.dev Reference Go Tests JS Tests Builds

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 git@github.com: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.

$ 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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cmd contains all of the CLI commands
Package cmd contains all of the CLI commands
pkg

Jump to

Keyboard shortcuts

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