docker run -p 8080:8080 ghcr.io/vyuvaraj/servgate:latestServGate is a high-performance, programmable API Gateway and reverse proxy tailored for the Serv ecosystem. Its primary differentiating feature is WASM-Powered Middleware: the ability to execute sandboxed WebAssembly (WASI) modules inline on incoming request or response cycles to inspect, validate, or mutate payloads before forwarding.
- Reverse Proxy: Dynamic path-based routing (e.g.
/api/v1/orders/*->http://127.0.0.1:8081) with automatic URL prefix stripping. - WASM Inline Middleware: Execute guest WASI filters to validate headers, manipulate query params, or enrich body payloads.
- Distributed Observability: Seamless trace propagation using OpenTelemetry standard headers (
traceparent) and JSON-based OTLP span exports. - Authentication Security: Build-in OAuth2 Bearer token checks for all routed backend targets.
Ensure you have Go installed, then compile and run:
go build -o servgate.exe main.go
./servgate.exe- The API Gateway reverse proxy listens on
:8080(configured viaconfig.json). - Dynamic middleware registration is managed via
/api/admin/middleware/{name}.
Manage routes declaratively:
{
"addr": ":8080",
"auth_token": "gateway-secret-token",
"routes": [
{
"prefix": "/api/v1/orders",
"target": "http://127.0.0.1:8081",
"middleware": "validator"
}
]
}Register a compiled .wasm middleware:
curl -X POST http://localhost:8080/api/admin/middleware/validator \
-H "Authorization: Bearer gateway-secret-token" \
--data-binary @my_validator.wasmRun integration tests:
go test ./... -vServGate can act as a high-performance standalone API Gateway in front of non-ecosystem applications built with frameworks like Node.js (Express), Python (Flask), or Java (Spring Boot) without requiring any WebAssembly filters:
To forward client requests dynamically from ServGate to an Express app listening on :3000:
- Configure a path-based routing rule in
config.json:{ "prefix": "/api/users", "target": "http://localhost:3000" } - Requests to
http://localhost:8080/api/users/profilewill be automatically stripped and routed tohttp://localhost:3000/profile.
For Flask APIs running on port :5000:
- Add the routing target rule to your
config.jsonlist:{ "prefix": "/api/predict", "target": "http://localhost:5000" } ServGatehandles HTTP headers forwarding, logging, and connection pooling out-of-the-box.
For Spring Boot controllers running on port :8080 (or custom port :8081):
- Configure the target path mappings:
{ "prefix": "/api/v1/billing", "target": "http://localhost:8081" }
Create a config.json file combining your multi-backend routing policies:
{
"addr": ":8080",
"auth_token": "gateway-secret-token",
"routes": [
{
"prefix": "/api/users",
"target": "http://localhost:3000"
},
{
"prefix": "/api/predict",
"target": "http://localhost:5000"
},
{
"prefix": "/api/v1/billing",
"target": "http://localhost:8081"
}
]
}Start the gateway pointing directly to your custom config file:
./servgate.exe --standalone --config config.jsonThe gateway is now running at http://localhost:8080, proxying requests dynamically based on prefixes!