A Go proxy to plug between the frontend and the backend or between backend services for last-resort testing.
I only want to see the requests and responses, without the necessity to open a debugger.
make buildor if you don't have Make:
go build github.com/blazejsewera/go-test-proxy/cmd/gotestproxy./gotestproxy --target=https://example.com --port=8000Depending on your project, you want to have something like this:
backendUrl: "http://localhost:8000"It is easy to quickly mock endpoints with Go Test Proxy, simply add a new handler function to the proxy builder.
Go to main.go and invoke builder.WithHandlerFunc("/mockedPath", customFunc).
Then rebuild the project and run it.
Look at builder.WithMonitor and monitor.Combine functions.
The former lets you set any monitor adhering to the proxy.Monitor interface.
The latter lets you combine multiple monitors — they will be called one-by-one.
To install gotestproxy binary, simply run make install,
setting a PREFIX that is in your PATH.
PREFIX=<target_directory> make installUninstalling is also very simple:
PREFIX=<previously_set_prefix> make uninstallAlternatively, you can simply remove the gotestproxy binary — it's self-contained,
so it's the only file to remove.
You can also build gotestproxy for different targets, like windows/amd64:
make build-windows-amd64