import { ServiceBindingRouter } from "https://deno.land/x/keywork@v6.2.1/middleware/classes/mod.ts";
A router that proxies requests directly to a Cloudflare Worker environment binding, such as a service binding.
Middleware in Keywork can also be thought of as any object that implements the Keywork#Router.Fetcher | Fetcher
interface.
Under the hood, Keywork#Router.RequestRouter | RequestRouter
is a Fetcher
,
and is the most common usage of middleware.
Cloudflare's concept of "environment bindings" almost satisfy the Fetcher
interface,
and with the help of the ServiceBindingRouter
class, they can be used as middleware within Keywork!
Combining Multiple Workers
The ServiceBindingRouter
class proxies requests directly to an environment binding,
such as a service binding configured in your project's wrangler.toml
,
allowing you to compose your app from multiple Workers, regardless if they use Keywork or not.