___ _
| __|__| |_ ___
| _|/ _| ' \/ _ \
|___\__|_||_\___/
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 | * | |
| 2 | Endpoint | * | |
| 3 | Status code | 200 |
| Key | Method | Endpoint | Status code |
|---|---|---|---|
| GET:/orders | GET | /orders | 200 |
| POST:/orders:201 | POST | /orders | 201 |
| GET:/orders/1:404 | GET | /orders/1 | 404 |
| GET:/orders/2:500 | GET | /orders/2 | 500 |
{
"GET:/v1/orders/1": {
"id": 1,
"status": "confirmed"
},
"POST:/v1/orders:201": {
"success": true
}
}echo routes.jsonOptions:
--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 exitcurl 127.0.0.1:8080/v1/orders/1curl -X POST 127.0.0.1:8080/v1/ordersRedirect all non-defined routes to the specified host:
{
"*": "https://jsonplaceholder.typicode.com"
}Override a specific route:
{
"*": "https://jsonplaceholder.typicode.com",
"GET:/todos/1": {
"id": 1,
"userId": 1,
"title": "default",
"completed": false
}
}