· Iren Saltali · operations · 2 min read
Config-Driven Gateways vs. Code-Driven Gateways
A guide to when a declarative gateway model helps teams move faster and when custom code is still the better choice.
The short answer: Config-driven gateways work best when most route behavior is predictable and reviewable; code-driven gateways win when each route has unusual or deeply custom logic.
When to read this
- You are choosing how your team will own API behavior.
- You need a decision memo for platform contributors.
- You want to reduce bespoke routing logic over time.
What matters in practice
- Config improves readability and reviewability for common gateway behavior.
- Custom code is still right when the product logic is far beyond routing, auth, and mapping.
- The healthiest setup is often a config baseline plus targeted custom Worker services.
Concrete example
{
"servers": [
{ "alias": "orders", "url": "https://orders.example.com" }
],
"variables": {
"region": "eu-west-1"
},
"paths": [
{
"method": "GET",
"path": "/orders/{.+}",
"integration": { "type": "http_proxy", "server": "orders" },
"mapping": {
"headers": {
"x-region": "$config.region"
}
}
}
]
}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
- The config model does not cover every possible edge behavior.
- This repo intentionally favors a smaller, understandable config surface over endless abstraction.
FAQ
Can I mix config and code here?
Yes. Proxy, service, and service-binding integrations let you keep the baseline declarative while extending where needed.
What is the biggest benefit of config?
Consistency in review, docs, and onboarding for common API concerns.
Related docs
- serverless api gateway vs cloudflare workers hand rolled
- service vs service binding
- config schema overview
Last reviewed: March 6, 2026