Mocktane is a high-octane mock server built in Rust, designed for easy and efficient API mocking. It takes in a JSON configuration and serves endpoints with a variety of HTTP methods, providing mock responses to help you test your client-side code without the need for a live backend.
- 🏎️ High-Performance: Handles 20,000 RPS with 100 concurrent connections and a typical response time of ~5ms, even on a standard laptop.
- 📦 Compact: The compiled binary is under 7MB in size.
- 🌐 Simple API Mocking: Easily configure mock endpoints using simple JSON.
- 🔧 Customizable: Define responses for different HTTP methods and paths.
- 💡 Quick Setup: Get your mock server up and running in seconds.
- 🖥️ JSON Responses: Mock APIs with structured, JSON responses.
-
Clone the Repository:
git clone https://github.com/Nan0Scho1ar/mocktane.git cd mocktane -
Build the Project:
Make sure you have Rust installed. If you don't, install it from rust-lang.org.
cargo build --release
-
Install the compiled binary:
cargo install --path .
Mocktane can be run by providing a JSON configuration that defines your mock endpoints.
mocktane '<endpoints-definition>'Where <endpoints-definition> is a string containing a JSON array of endpoints.
[
{
"path": "/api/user",
"method": "GET",
"response": {
"id": 1,
"name": "John Doe"
}
},
{
"path": "/api/products",
"method": "POST",
"response": {
"id": 101,
"name": "Cool Widget"
}
}
]mocktane '[{"path":"/api/user","method":"GET","response":{"id":1,"name":"John Doe"}},{"path":"/api/products","method":"POST","response":{"id":101,"name":"Cool Widget"}}]'Once started, Mocktane will listen on port 8080. You can interact with the mock server via HTTP requests.
- GET /api/user → Returns
{"id":1,"name":"John Doe"} - POST /api/products → Returns
{"id":101,"name":"Cool Widget"}
Mocktane is designed to accept a JSON array with endpoint definitions. Each endpoint specifies:
- path: The URL path for the mock endpoint.
- method: The HTTP method (GET, POST, etc.).
- response: The JSON response body to return.
It listens for incoming HTTP requests, parses the request, and responds with the appropriate mock data from the JSON configuration.
Mocktane is licensed under the GPL-3.0 License. See the LICENSE file for more information.