| Crates.io | mockserver |
| lib.rs | mockserver |
| version | 0.1.6 |
| created_at | 2025-03-17 19:03:22.333181+00 |
| updated_at | 2025-03-19 14:47:06.662879+00 |
| description | A lightweight, file-based mock API server written in Rust. |
| homepage | |
| repository | https://github.com/sfeSantos/mockserver |
| max_upload_size | |
| id | 1595812 |
| size | 92,615 |
This project is a dynamic mock server written in Rust. It reads a YAML configuration file to define API endpoints, supported HTTP methods, and response files. The main goal is to provide a simple, file-based mock API server that supports:
204 No Content.responses/ directory.Many developers need quick and flexible mock servers to simulate backend APIs during frontend or integration testing. This project provides a lightweight and fast alternative to heavy solutions like JSON Server or WireMock.
warp and tokio for high-performance asynchronous processing.config.yaml file.POST/PUT.config.yaml file using a command-line argument (--file).--port.--responses-folderdelay field in config.yaml.delay field in config.yaml.
GET, POST).429 status code when the rate limit is exceeded../mockserver --file config.yaml --port 8080 --responses-folder folder_location
.exe and then run the following line:
.\mockserver.exe --file config.yaml --port 8080 --responses-folder folder_location
config.yaml with your configuration file.8080 with the desired port.folder_location with the directory for mock responses./api/user:
method: GET
file: user_response.json
authentication:
basic:
user: 'admin'
password: 'secret'
/api/order:
method: POST
file: order_data.json
status_code: 202 #custom Http status code
authentication:
bearer:
token: 'valid_token'
claims:
role: 'admin'
This means:
GET /api/user → Returns response/user_reponse.jsonPOST /api/order → Returns response/order_data.jsoncargo run
Server starts on http://localhost:8080
curl http://localhost:8080/api/user
curl -X POST http://localhost:8080/api/order -d '{"item": "Laptop"}' -H "Content-Type: application/json"
curl -X DELETE http://localhost:8080/api/order
cargo test
Contributions are welcome! Feel free to submit issues or pull requests.
This project is licensed under the MIT License - see the full details at MIT License.