· Iren Saltali · architecture · 2 min read
Worker-to-Worker Service Composition Explained
How service bindings let the gateway call Worker methods directly when plain HTTP proxying is not the right fit.
The short answer: Use service bindings when the gateway and the target service both live in the Worker environment and you want a tighter, explicit integration than HTTP proxying.
When to read this
- Both the gateway and target functionality live on Cloudflare Workers.
- You want explicit method calls instead of external HTTP hops.
- You need pre-process or post-process hooks around the service call.
What matters in practice
- Service bindings are best for Worker-native composition.
- Keep function names small and stable because the route config depends on them.
- Document the contract of each bound method like any other API surface.
Concrete example
{
"serviceBindings": [
{ "alias": "hooks", "binding": "HOOKS" },
{ "alias": "target", "binding": "TARGET" }
],
"paths": [
{
"method": "POST",
"path": "/orders",
"pre_process": { "binding": "hooks", "function": "before" },
"integration": { "type": "service_binding", "binding": "target", "function": "run" }
}
]
}The example above is intentionally small because the best gateway configs stay readable. Add only the route, auth, and mapping behavior you actually need.
How this maps to the current gateway
The current codebase already supports the behavior discussed here through its config schema, route matcher, and integration handlers. That is why this project is a good fit for reader-first examples: the docs and blog can point to real, implemented behavior instead of hypothetical gateway features.
What this product does not do
- Service bindings do not replace good service boundaries.
- This repo does not add distributed tracing or workflow visualization automatically.
FAQ
Is service binding faster than HTTP proxying?
It can remove an external network hop, but the main reason to choose it is a clearer Worker-to-Worker contract.
Can I still return JSON easily?
Yes. The gateway wraps service results into the standard JSON response format.
Related docs
- service binding worker methods
- pre process hooks
- post process hooks auth0 callback
Last reviewed: March 6, 2026