Gateway Plugin Runtime
request → auth → policy → wasm hooks → channel relay → wasm stream/response hooks → audit
Gateway Plugin Runtime
Architecture
1request → auth → policy → wasm hooks → channel relay → wasm stream/response hooks → audit
internal/wasmhost/ is responsible for:
- Manifest discovery and loading (
loader.go) - Built-in plugins (
builtin.go,wasm.binary: builtin:*) - wazero external wasm placeholder (
runtime.go+WazeroPlugin) - fsnotify hot reload (
manager.go)
ABI subset
| Hook | Description |
|---|---|
OnRequestHeaders | Request-header stage |
OnRequestBody | Request body (including WAF) |
OnResponseBody | Non-streaming response rewrite |
OnStreamChunk | SSE chunk rewrite |
Returns ActionContinue / ActionStop; on Stop the gateway writes back StopBody directly.
Manifest
yaml
1runtime: wasm2enabled: true3priority: 1004scope:5 tenant_ids: ["*"]6 routes: ["/v1/*"]7wasm:8 binary: builtin:keyword-rewrite9 host_capabilities: [audit_log, metrics_inc]10config:11 replacements:12 secret-keyword: "[REDACTED]"
Ops APIs (internal)
GET /internal/pluginsPOST /internal/plugins/reloadPOST /internal/plugins/uploadGET /internal/errors— 24h error fingerprint clusteringPOST /internal/channels/{id}/probe— Channel self-checkGET /internal/perf— Pyroscope configuration
Made-with: Damon Li