File-based routing
The server uses your directory structure to automatically serve the correct response. When a request comes in, it checks your directories and files (like data.json for /data) to find a match for the URL. All you need to do is organize your files and directories where the server is running.
Example Directory Structure
Here's an example of how you might set up:
(root)/
└── api/
└── v1/
├── status.json
├── user/
│ ├── 1.json
│ └── 2.json5
└── users.csv
- A request to
/api/v1/statusreturnsstatus.json. /api/v1/user/1returns the content of1.json./api/v1/user/2returns the content of2.json5..json5is equivalent to.jsonto the server./api/v1/usersreturns the content ofusers.csvas list.- Each of
/,/apiand/api/v1returns HTTP Status Code 404- unless an "index" file (e.g.,
index.json,.json5, or.csv. Also.html) is present in the respective directory.
- unless an "index" file (e.g.,
What's next ?
File-based routing is great for simple cases where your response directly maps to a URL. It gets you up and running quickly for many basic mocking needs.
Expanding Your Mock Server's Capabilities
However, you'll quickly discover some limitations. For instance, you can't create responses that depend on request headers or body data, limiting your flexibility.
When your mocking needs go beyond basic URL matching, rule-based configuration becomes incredibly powerful. This approach gives you much more control, but it requires a configuration file. Don't worry, we'll walk you through setting it up so you can harness its full potential !