httmock
allows local testing and prototyping by mocking a HTTP server from a file based specification.
- Clone this repository:
git clone https://github.com/benmezger/httmock
: - Run
make install
Make sure you have a .http.yaml
in your current directory or pass a custom filename with --api-file
httmock serve
orhttmock --api-file <filename> serve
Use httmock serve --host localhost:8000
for using a different host/port.
For listing routes with their available params, use:
httmock list
orhttmock --api-file <filename> list
For an example of the file structure, see example-http.yaml.
- Handle context base requests and responses
Run httmock
with the example file
Then run curl against the defined URL paths:
curl -X GET http://localhost:8000/?name=name-param -d '{"msg": "Body of GET request"}'
{"msg": "Hello, from / GET response"}