Skip to content

Nan0Scho1ar/mocktane

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mocktane: The High-Octane Mock Server

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.

Features

  • 🏎️ 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.

Installation

  1. Clone the Repository:

    git clone https://github.com/Nan0Scho1ar/mocktane.git
    cd mocktane
  2. Build the Project:

    Make sure you have Rust installed. If you don't, install it from rust-lang.org.

    cargo build --release
  3. Install the compiled binary:

    cargo install --path .

Usage

Running Mocktane

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"
        }
    }
]

Example:

mocktane '[{"path":"/api/user","method":"GET","response":{"id":1,"name":"John Doe"}},{"path":"/api/products","method":"POST","response":{"id":101,"name":"Cool Widget"}}]'

Running the Server

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

How It Works

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.

License

Mocktane is licensed under the GPL-3.0 License. See the LICENSE file for more information.

About

High Octane Mock API Server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors