Quick Usage
Installation
1. Homebrew (macOS and Linux) v3.2.5
brew tap gripmock/tap
brew install --cask gripmock
gripmock --version2. Shell script (curl)
Linux and macOS, arm64 and amd64:
curl -s https://raw.githubusercontent.com/bavix/gripmock/refs/heads/master/setup.sh | sh -sThis script automatically:
- Detects your system (Linux/macOS) and architecture (arm64/amd64)
- Checks system dependencies
- Downloads the latest release securely
- Validates checksums
- Installs to your system PATH
3. Download Pre-built Binaries
Ready-to-use binaries for various platforms are available on the Releases page. Download the right binary for your system and add it to your PATH.
4. Using Docker
GripMock comes as a Docker image for easy use. Make sure Docker is installed:
Install Docker.
Pull the latest GripMock Docker image:
docker pull bavix/gripmock5. Using Go
If you have Go installed, you can install GripMock directly:
go install github.com/bavix/gripmock/v3@latestPreparation
Assume we have a gRPC service defined in simple.proto:
syntax = "proto3";
package simple;
service Gripmock {
rpc SayHello (Request) returns (Reply);
}
message Request {
string name = 1;
}
message Reply {
string message = 1;
int32 returnCode = 2;
}Run GripMock
Single Service (Traditional .proto)
docker run \
-p 4770:4770 \
-p 4771:4771 \
-v ./api/proto:/proto:ro \
bavix/gripmock /proto/simple.protoUsing Proto Descriptors (New)
GripMock now supports compiled proto descriptors (.pb files) for better dependency management:
Generate descriptor file: Using Protocol Buffers Compiler (
protoc):bashprotoc --proto_path=. --descriptor_set_out=service.pb service.protoOr using Buf (modern build tool):
bashbuf build -o service.pbRun with descriptor:
bashdocker run \ -p 4770:4770 \ -p 4771:4771 \ -v ./api/proto:/proto:ro \ bavix/gripmock /proto/service.pb
Note:
- When using
protoc, add--include_importsfor multi-file dependencies- Buf automatically handles dependencies and requires no extra flags
- Descriptors package services/dependencies into a single binary file
- Buf requires a valid
buf.yamlconfiguration in your project
Multiple Services
Option 1: Specify Multiple Files
docker run \
-p 4770:4770 \
-p 4771:4771 \
-v ./protos:/proto:ro \
bavix/gripmock /proto/service1.proto /proto/service2.protoOption 2: Auto-Load Folder
Mount a directory containing multiple .proto and .pb files:
docker run \
-p 4770:4770 \
-p 4771:4771 \
-v ./protos:/proto:ro \
bavix/gripmock /protoThis will automatically load all .proto and .pb files in the /proto directory.
Note:
- All
.protoand.pbfiles in the specified directory will be processed- Ensure there are no conflicting service/message definitions across files
- Subdirectories are scanned recursively
- Important: If duplicate services are found in both
.protoand.pbfiles, GripMock will fail to start. In such cases, specify files manually instead of using folder auto-load.
Load from Buf Schema Registry (BSR) v3.8.4
You can start GripMock from a BSR module reference directly:
gripmock --stub ./stubs buf.build/connectrpc/elizaSee the dedicated BSR page for refs, private modules, and env vars: BSR.
Web UI (v3.0+)
Access the admin panel at:
http://localhost:4771/ (default port).
Features:
- Create, edit, and delete stubs.
- View lists of used/unused stubs.
Stubbing
Dynamic Stubs (API)
Add a stub via curl:
curl -X POST -d '{
"service": "Gripmock",
"method": "SayHello",
"input": { "equals": { "name": "gripmock" } },
"output": { "data": { "message": "Hello GripMock" } }
}' http://127.0.0.1:4771/api/stubsResponse (stub ID):
["6c85b0fa-caaf-4640-a672-f56b7dd8074d"]Static Stubs (YAML/JSON)
Mount a stubs directory and use --stub:
docker run ... -v ./stubs:/stubs bavix/gripmock --stub=/stubs /proto/simple.protoVerification
Check Stubs
- API:bash
curl http://127.0.0.1:4771/api/stubs - UI: Visit http://localhost:4771/ and navigate to the stubs section.
Advanced Features
Binary Descriptor Support v3.1.0
When using .pb descriptors:
- No need for original
.protofiles in the container - Faster startup with pre-compiled definitions
- Better handling of complex proto dependencies
- Supports all features available with regular
.protofiles
Tip: Use Buf for modern proto workflows:
bashbuf build --exclude-source-info -o service.pbThis creates leaner descriptors optimized for runtime use
Headers Matching v2.1.0
Add headers to stubs for fine-grained control:
{
"headers": {
"equals": { "authorization": "Bearer token123" }
},
"input": { ... },
"output": { ... }
}Array Order Flexibility v2.6.0
Use ignoreArrayOrder: true to disable array sorting checks:
{
"input": {
"ignoreArrayOrder": true,
"equals": { "ids": ["id2", "id1"] }
}
}Health checks v2.0.2
Check service status:
curl http://127.0.0.1:4771/api/health/liveness
curl http://127.0.0.1:4771/api/health/readinessPlugins v3.5.0
Extend template functions with custom plugins:
# Build plugins
make plugins
# Load plugins
gripmock --plugins=./plugins/hash.so --plugins=./plugins/math.so service.protoUse plugin functions in dynamic templates:
output:
data:
hash: "{{.Request.data | sha256}}"
result: "{{pow .Request.base .Request.exponent}}"See Plugins for detailed documentation.
Cleanup
- Delete all stubs:bash
curl -X DELETE http://127.0.0.1:4771/api/stubs - Delete specific stub:bash
curl -X DELETE http://127.0.0.1:4771/api/stubs/{uuid}