Skip to content

lynicis/inzibat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

110 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Inzibat πŸͺ–

Release Version Quality Gate Coverage Go Version License

Inzibat (from Turkish, meaning "Military Police") is a lightweight, fully-customizable HTTP mock server designed for microservices testing and development. Built in Go and powered by Fiber, it provides a fast and simple way to simulate downstream services through declarative configuration files.

Perfect for frontend development, backend integration testing, and CI/CD pipelinesβ€”configure your mock responses in JSON, TOML, or YAML without writing a single line of server code.


🧭 Table of Contents

✨ Key Features

  • Lightweight HTTP mock server implemented in Go
  • Config-driven (JSON, TOML, YAML) for easy scenario definition
  • Fast β€” built on top of Fiber (which uses fasthttp)
  • Simple, declarative API for defining routes and responses

🎯 Why Inzibat?

  • For Frontend Teams: Get predictable API responses for your UI development without waiting for the backend.
  • For Backend Teams: Isolate your service during integration testing by mocking downstream dependencies.
  • For CI Pipelines: Run reliable end-to-end tests by simulating third-party APIs.
  • No-Code Scenarios: Implement complex mock behavior without writing a single line of server code.

πŸ› οΈ Installation

From Releases (Recommended)

This is the easiest way to get inzibat for most users.

  1. Go to the Releases Page.
  2. Download the archive matching your OS and architecture (e.g., inzibat_linux_amd64.tar.gz).
  3. Extract the archive and move the inzibat binary to a directory in your system's PATH.
# Example for Linux/macOS
tar -xzf inzibat_linux_amd64.tar.gz
sudo mv inzibat /usr/local/bin/

Homebrew (macOS / Linux)

brew tap lynicis/tap
brew install inzibat

Chocolatey (Windows)

choco install inzibat

Scoop (Windows)

scoop bucket add inzibat https://github.com/lynicis/scoop-bucket.git
scoop install inzibat

Linux Packages (deb / rpm)

Pre-built .deb and .rpm packages are attached to each release.

Debian / Ubuntu

curl -LO https://github.com/lynicis/inzibat/releases/latest/download/inzibat_linux_amd64.deb
sudo dpkg -i inzibat_linux_amd64.deb

Fedora / CentOS / RHEL

sudo rpm -i https://github.com/lynicis/inzibat/releases/latest/download/inzibat_linux_amd64.rpm

From Source

If you have Go 1.25+ installed, you can build inzibat from source.

Option 1: Quick Install

go install github.com/lynicis/inzibat@latest

This installs the latest version to your $GOPATH/bin directory.

Option 2: Build from Clone

For development or custom builds:

git clone https://github.com/Lynicis/inzibat.git
cd inzibat
go build -o inzibat .

This creates a local inzibat binary in the project directory.


πŸš€ Quick Start

Get a mock server running in under 30 seconds.

Step 1: Create a Configuration File

Create a file named inzibat.json (or inzibat.yml, inzibat.toml) in your current directory:

# inzibat.yml
port: 8080
routes:
  - path: /api/hello
    method: GET
    response:
      status_code: 200
      headers:
        Content-Type: application/json
      body: '{"message": "Hello, World!"}'

Step 2: Start the Server

Run Inzibat:

inzibat start
# or use the short alias
inzibat s

The server will start on port 8080 (or the port specified in your config).

Step 3: Test It

In another terminal, send a request:

curl http://localhost:8080/api/hello

You should receive:

{"message": "Hello, World!"}

πŸ’» CLI Commands

Inzibat provides a powerful CLI for managing routes and starting the server interactively.

Start Server

Start the mock server with the start command:

# Start with default config (inzibat.json in current directory)
inzibat start

# Use the short alias
inzibat s

# Specify a custom config file
inzibat start --config /path/to/config.yml
inzibat start -c /path/to/config.yml

# Use the global config stored at ~/.inzibat.config.json
inzibat start --global

Configuration Precedence:

The server reads configuration in the following order:

  1. File specified by the --config / -c flag
  2. File specified by the INZIBAT_CONFIG_FILE environment variable
  3. inzibat.json in the current working directory

Use the --global (-g) flag to bypass this order and load the global config at ~/.inzibat.config.json.

Create Routes

Create new routes interactively using the create command:

# Launch interactive route creation (saves to inzibat.json in current directory)
inzibat create

# Or use the short alias
inzibat c

# Create route in a custom config file
inzibat create --config /path/to/config.json
inzibat create -c /path/to/config.json

# Create route in the global config file (~/.inzibat.config.json)
inzibat create --global
inzibat create -g

The interactive form guides you through:

  • Setting the route path and HTTP method
  • Choosing between mock responses or proxy routes
  • Configuring response status codes, headers, and body
  • Setting up proxy targets for client routes

Configuration Precedence:

Routes are saved to the configuration file in the following order:

  1. File specified by the --config / -c flag
  2. File specified by the INZIBAT_CONFIG_FILE environment variable
  3. inzibat.json in the current working directory
  4. ~/.inzibat.config.json if --global / -g flag is used

List Routes

View all configured routes:

# List all routes from inzibat.json in current directory
inzibat list

# Or use the short aliases
inzibat ls
inzibat l

# List routes from a custom config file
inzibat list --config /path/to/config.json
inzibat list -c /path/to/config.json

# List routes from the global config file (~/.inzibat.config.json)
inzibat list --global
inzibat list -g

This displays all routes from your configuration file in a structured, easy-to-read format.

Configuration Precedence:

Routes are read from the configuration file in the following order:

  1. File specified by the --config / -c flag
  2. File specified by the INZIBAT_CONFIG_FILE environment variable
  3. inzibat.json in the current working directory
  4. ~/.inzibat.config.json if --global / -g flag is used

Command Aliases

For convenience, all commands have shorter aliases:

Command Aliases
start start-server, server, s
create create-route, c
list list-routes, ls, l

πŸ“Ή Request Recorder

Inzibat features a Request Recorder that intercepts and stores incoming HTTP requests and responses flowing through the mock/proxy server, allowing you to export them as raw JSON or convert them directly into native Inzibat mock configurations for testing.

Start Recording

Start the server with the --record (or -r) flag to enable the request recorder:

# Start server with recording enabled
inzibat start --record
# Or
inzibat start -r

Export Session

Use the record command group to interact with the recorded session:

# List all captured requests (IDs, methods, paths, status codes, duration)
inzibat record list
# Or
inzibat record ls

# Export the raw session data to a JSON file
inzibat record export -o session.json

# Convert and export the session specifically into the Inzibat mock format
inzibat record export --format inzibat -o my-mocks.json

Clear Session

To clear all captured requests from the session store:

# Clear the captured requests
inzibat record clear

Admin API

When recording is enabled, you can also manage the recording store programmatically via the built-in HTTP Admin API:

  • GET /_inzibat/recorder/entries β€” Returns all captured entries in the session.
  • GET /_inzibat/recorder/session β€” Returns the current recorder session with metadata.
  • POST /_inzibat/recorder/clear β€” Clears the recorder store.

πŸ§ͺ Testing

Run the test suite:

# Run all tests
go test ./... -v

# Run tests with coverage
go test ./... -cover

# Run tests for a specific package
go test ./handler -v

πŸ“ Configuration

Inzibat supports configuration files in JSON, TOML, and YAML formats.

Basic Configuration Structure

{
  "$schema": "https://raw.githubusercontent.com/lynicis/inzibat/refs/heads/master/examples/inzibat.schema.json",
  "serverPort": 8080,
  "concurrency": 5,
  "circuitBreaker": {
    "enabled": true,
    "failureThreshold": 5,
    "minimumRequests": 10,
    "openTimeoutMs": 30000,
    "halfOpenMaxRequests": 2,
    "successThreshold": 2
  },
  "routes": [
    {
      "method": "GET",
      "path": "/proxy/users",
      "requestTo": {
        "method": "GET",
        "host": "http://localhost:8081",
        "path": "/users",
        "passWithRequestHeaders": true,
        "passWithRequestBody": false,
        "inErrorReturn500": false,
        "circuitBreaker": {
          "enabled": true,
          "failureThreshold": 3
        }
      }
    },
    {
      "method": "GET",
      "path": "/mock/health",
      "fakeResponse": {
        "statusCode": 200,
        "body": {
          "status": "ok"
        }
      }
    }
  ]
}

Route Types

  • Mock Routes: Use fakeResponse to return predefined status, headers, and body
  • Proxy Routes: Use requestTo to forward requests to upstream services

Circuit Breaker

  • Circuit breaker applies only to proxy routes (requestTo)
  • Failure signal is network errors and 5xx responses; 4xx responses do not trip the breaker
  • You can configure breaker globally (circuitBreaker) and override per-route (requestTo.circuitBreaker)

🀝 Contributing

Contributions are welcome! We appreciate your help in making Inzibat better.

Getting Started

  1. Fork the repository and clone your fork

  2. Create a feature branch (git checkout -b feature/my-new-feature)

  3. Make your changes and add tests for any new behavior

  4. Run the tests to ensure everything passes:

    go test ./... -v
  5. Commit your changes with clear, descriptive messages

  6. Push to your fork and open a Pull Request

Guidelines

  • Follow Go best practices and conventions
  • Add tests for new features and bug fixes
  • Update documentation as needed
  • Keep commits focused and atomic
  • Write clear commit messages

Reporting Issues

For bug reports or feature requests, please open an issue with:

  • A clear description of the problem or feature request
  • Steps to reproduce (for bugs)
  • Expected vs. actual behavior
  • Environment details (OS, Go version, etc.)

Roadmap

See ROADMAP.md for planned features and improvements.

We welcome feedback, feature suggestions, and contributions to help advance Inzibat's capabilities. If you notice gaps in feature coverage or want to propose an enhancement, please open an issue or Pull Request!

πŸ“œ License

This project is licensed under the MIT License β€” see the LICENSE file for details.

About

Simple Mock Service for Microservices

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

Used by

Contributors

Languages