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.
brew install aaronvb/request_hole/rh
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
Download the release version for your system: https://github.com/aaronvb/request_hole/releases
$ 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.
$ 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.
$ 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.
To create an http endpoint with default settings (port 8080, return status code 200):
$ rh http
To create a WebSocket endpoint with default settings (port 8080):
$ rh ws
This option shows all the header details in the incoming request.
$ rh http --details
This option will write the CLI output to the specified log file. Works with other options such as --details
.
$ rh http --log rh.log
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
It is recommended to run the JS build first so that the Go build can embed the latest web UI build.
$ go test -v ./...
$ go build
$ cd web; yarn test
$ cd web; yarn build
$ cd web; yarn start
Visit localhost:3000
- 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