___ _
| __|__| |_ ___
| _|/ _| ' \/ _ \
|___\__|_||_\___/
Echo -- easy-to-use mock server that accelerates api emulation with json.
- simple json format
- response latency
- reverse proxy mode
- request and response logs
The json format is as follows:
- key -- route
- value -- response
The key is a colon-separated string which contains 3 parts:
# | Part | Required | Default |
---|---|---|---|
1 | Method | GET | |
2 | Code | 200 | |
3 | Path | * |
Key | Method | Path | Code |
---|---|---|---|
/orders | GET | /orders | 200 |
404:/orders/1 | GET | /orders/1 | 404 |
GET:/orders/2 | GET | /orders/2 | 200 |
POST:201:/orders | POST | /orders | 201 |
{
"/v1/orders/1": {
"id": 1,
"status": "confirmed"
},
"POST:201:/v1/orders": {
"success": true
}
}
echo routes.json
Options:
--port PORT, -p PORT port [default: 8080]
--color, -c color output [default: true]
--latency LATENCY, -l LATENCY
response latency [default: 0]
--print PRINT string specifying what the output should contain:
'H' request headers
'B' request body
'h' response headers
'b' response body
--verbose, -v verbose output
--help, -h display this help and exit
--version display version and exit
curl 127.0.0.1:8080/v1/orders/1
curl -X POST 127.0.0.1:8080/v1/orders
Redirect all non-defined routes to the specified host:
{
"*": "https://jsonplaceholder.typicode.com"
}
Override a specific route:
{
"*": "https://jsonplaceholder.typicode.com",
"/todos/1": {
"id": 1,
"userId": 1,
"title": "default",
"completed": false
}
}