DEV Community

Azizul Haque Ananto
Azizul Haque Ananto

Posted on

Create your own blazing fast mock server with just a JSON file!

TLDR; https://github.com/Ananto30/mocker

The idea is really simple. Just create high-performing πŸš€ mock servers using a json file that maps path to status code and response body.

This can be used to benchmark your microservices, that are dependant on other HTTP services.

This is a sample mock file -

{
  "/hello/worlds": {
    "statusCode": 200,
    "responseBody": {
      "message": "Hello worlds!",
      "data" : {
        "time": "now"
      },
      "worlds": [
        "cross origin world",
        "mars world",
        "moon world"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Then just run -

./mocker -addr <YOUR_HOST_AND_PORT> -file <MOCK_JSON_FILE_LOCATION>
Enter fullscreen mode Exit fullscreen mode

In windows -

mocker.exe -addr <YOUR_HOST_AND_PORT> -file <MOCK_JSON_FILE_LOCATION>
Enter fullscreen mode Exit fullscreen mode

Please report bugs and suggest new features and ideas. πŸ‘‡

Top comments (0)