ResponseMate is a command line tool that helps inspecting and recording HTTP requests/responses from a terminal.
It is designed with APIs in mind.
gem install response_mate
For a list of available commands run response_mate help
For help on a command run response_mate help some_command
Most ResponseMate's tasks depend on a manifest file where you declare
the requests to be made.
The default filename of this manifest is requests.yml
.
You may specify another file using the -r
option.
This file has to be in YAML format (but keep in mind
that JSON is a valid compatible subset of YAML).
Example:
default_headers:
accept: 'application/vnd.{{app_name}}.beta+json'
requests:
-
key: user_issues
request:
url: 'http://someapi.com/users/42/issues'
-
key: user_friends
request:
url: 'http://someapi.com/users/42/friends'
params:
since: 'childhood'
honest: '{{are_my_friends_honest}}'
Expressions inside {{}}
will be evaluated as
Mustache templates using values from a file
named environment.yml
.
You may specify a different location for the environment file using the
-e
option.
Example:
response_mate inspect issues_show -e ./response_mate/production_environment.yml
If your requests manifest does not contain Mustache tags you don't need an environment file.
In this file (default location: ./environment.yml
) you may place
variables to be used in the requests manifest.
Where applicable you may configure the location of the environment file
using the -e
option.
Example
response_mate record -e ./github/production_environment.yml
This file has to be in YAML format (but keep in mind that JSON is a valid compatible subset of YAML).
# environment.yml
base_url: http://api.github.com
repo: rails/rails
Then in the requests manifest any values of keys declared in the environment file can be used as follows.
# requests.yml
requests:
-
key: repos_show
url: {{base_url}}/repos/{{repo}}
Records the responses of HTTP requests declared in a requests manifest file.
response_mate record
By default responses are stored in the current working directory, but the output directory is configurable using the
-o
option.
Without any arguments / options it records all the keys of the requests manifest.
If you wish to record the responses of a subset of the declared requests
in the requests manifest, you may use the -k
option. You have to provide a space separated list of keys to be recorded.
response_mate record -k key1 key2
The requests are expected to be declared in a file named requests.yml
in the current working directory.
You may have many request files to use for various purposes.
To specify the one to be used you may supply the -r
option.
response_mate record -r github_api.yml
Performs the request and displays the output without recording
response_mate inspect some_key
Lists recording keys, prompting either to record or to inspect
response_mate list
Same as in the record command you may specify the output
directory using the -o
option.
Exports either the requests manifest or the environment file to a different format (currently only postman is supported)
response_mate export
response_mate export -f postman -p
response_mate export -f postman -r github_requests.yml
response_mate export --resource=environment
response_mate export --resource=environment --upload
Displays the version
Released under the MIT License. See the LICENSE file for further details.