🖥️ Try it yourself
$ spoof scaffold -o example-echo
Important
More token replacements are coming, so this document is a work in progress.
Keep an eye on this page for more enhancements.
You can include sections of the request in your response, by using {{tokens}} that are replaced in each response.
Here are some examples:
The following response will contain the entire body of the request.
"response": {
"statusCode": 200,
"body": {
"originalRequest": "{{request.body}}"
}
}If the request body is a plain text string, it will be returned in quotes, like this:
$ curl -s http://localhost:5050/api/echo --request POST --data "Hi!"
# Response
{
"originalRequest": "Hi!"
}If the original request body JSON, the JSON will be inserted in the correct place and re-formatted:
$ curl -s http://localhost:5050/api/echo --request POST --data "{ 'hello': 'world' }"
# Response
{
"originalRequest": {
"hello": "world"
}
}The response can also be a string, in which case the request body will be inserted in the correct place.
If the request body is JSON, it will be 'stringified'.
"response": {
"statusCode": 200,
"body": "You sent us: {{request.body}}"
}$ curl -s http://localhost:5050/api/echo --request POST --data "{ 'hello': 'world' }"
"You sent us: { 'hello': 'world' }"
$ curl -s http://localhost:5050/api/echo --request POST --data "{ 'hello': 'world' }"
"You sent us: Hi!"➡️ Next: Scaffolding