A Go implementation of the Imposter Mock Engine. This project is now considered stable.
- 💻 Run locally: Lightweight local HTTP mock server
- 🚀 Run in AWS Lambda: low latency, high throughput, <140ms cold start (see test results)
- ✅ REST/HTTP API mock support
- ✅ SOAP/WSDL mock support
- ✅ OpenAPI/Swagger mock support
- ✅ JavaScript scripting
- ✅ Support for steps
- ✅ Support for simulated delays, simulated errors and rate limiting
The recommended way to get started for most users is to use the latest Imposter CLI.
Note If you don't have Imposter CLI installed, or you want to use the
imposter-go
binary directly, continue to the Installation section.
With Imposter CLI installed, use the -t golang
option, and pass -v <version>
:
imposter up -t golang -v <version>
...where version
is from the Releases page, for example:
imposter up -t golang -v 0.15.0
Download the latest release for your platform from GitHub:
# For Intel Macs (x86_64)
curl -L https://github.com/imposter-project/imposter-go/releases/latest/download/imposter-go_Darwin_x86_64.tar.gz | tar xz
sudo mv imposter-go /usr/local/bin/
# For Apple Silicon Macs (arm64)
curl -L https://github.com/imposter-project/imposter-go/releases/latest/download/imposter-go_Darwin_arm64.tar.gz | tar xz
sudo mv imposter-go /usr/local/bin/
# For x86_64 systems
curl -L https://github.com/imposter-project/imposter-go/releases/latest/download/imposter-go_Linux_x86_64.tar.gz | tar xz
sudo mv imposter-go /usr/local/bin/
# For arm64 systems
curl -L https://github.com/imposter-project/imposter-go/releases/latest/download/imposter-go_Linux_arm64.tar.gz | tar xz
sudo mv imposter-go /usr/local/bin/
- Download the latest release from GitHub Releases
- Extract the
imposter-go_Windows_x86_64.zip
file - Add the extracted
imposter-go.exe
to your PATH or move it to a directory in your PATH
Run with a directory containing Imposter configuration file(s):
imposter-go ./examples/rest/simple
Visit http://localhost:8080/hello
in your browser or use curl
:
curl http://localhost:8080/hello
The repository includes several examples demonstrating different features:
- Simple REST API - Basic REST API mocking
- SOAP Web Service - SOAP/WSDL-based service mocking
- OpenAPI HTTP API - OpenAPI-based service mocking
- AWS Lambda - Running Imposter in AWS Lambda
A subset of the Imposter environment variables are supported. For example:
Set the IMPOSTER_PORT
environment variable to change the default port:
export IMPOSTER_PORT=9090 # Default: 8080
Enable recursive directory scanning for configuration files:
export IMPOSTER_CONFIG_SCAN_RECURSIVE=true # Default: false
Set the IMPOSTER_SERVER_URL
environment variable to override the URL reported by the server:
export IMPOSTER_SERVER_URL=http://example.com # Default: http://localhost:8080
Set the IMPOSTER_LOG_LEVEL
environment variable to control logging verbosity:
export IMPOSTER_LOG_LEVEL=DEBUG # Available levels: TRACE, DEBUG, INFO, WARN, ERROR
The default log level is DEBUG. Available log levels:
- TRACE - Most verbose, logs all messages
- DEBUG - Detailed information for debugging
- INFO - General operational messages
- WARN - Warning messages for potentially harmful situations
- ERROR - Error messages for serious problems
Imposter Go supports legacy configuration formats, for backwards compatibility with older Imposter configurations.
Enable support for legacy configuration format:
export IMPOSTER_SUPPORT_LEGACY_CONFIG=true
When legacy configuration support is enabled, older configuration formats are automatically transformed. For example:
# Legacy format (root-level fields)
plugin: rest
path: /hello
contentType: text/plain
response:
staticData: Hello, World!
# Legacy format (deprecated names for resource-level fields)
plugin: rest
resources:
- path: /hello
contentType: application/json
response:
staticFile: response.json # Deprecated, use file instead
staticData: Hello, World! # Deprecated, use content instead
scriptFile: transform.js # Deprecated, use a script step instead
See the Development Guide for instructions on building, testing, and contributing to the project.