Home

Awesome

  ___    _         
 | __|__| |_  ___  
 | _|/ _| ' \/ _ \ 
 |___\__|_||_\___/                 

Build Status Go Report Card

Echo -- easy-to-use mock server that accelerates api emulation with json.

Features

How to use

Create a mock file

The json format is as follows:

The key is a colon-separated string which contains 3 parts:

#PartRequiredDefault
1Method*
2Endpoint*
3Status code200

Mapping example

KeyMethodEndpointStatus code
GET:/ordersGET/orders200
POST:/orders:201POST/orders201
GET:/orders/1:404GET/orders/1404
GET:/orders/2:500GET/orders/2500

Example

{
  "GET:/v1/orders/1": {
    "id": 1,
    "status": "confirmed"
  },
  "POST:/v1/orders:201": {
    "success": true
  }
}

Go

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

Testing

curl 127.0.0.1:8080/v1/orders/1
curl -X POST 127.0.0.1:8080/v1/orders

Reverse proxy mode

Redirect 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
  }
}