request-classifier
v0.1.0
Published
```ts import { RequestClassifier } from "request-classifier";
Readme
Request Classifier
import { RequestClassifier } from "request-classifier";
const classifier = new RequestClassifier(
"shop.example.com",
[
{ kind: "api", matches: (ctx) => ctx.pathname.startsWith("/api") },
{ kind: "web", matches: () => true },
] as const,
{ pathname: "/api/orders" },
);
const response = await classifier.dispatch({
api: ({ pathname }) => handleApi(pathname),
web: () => handleWeb(),
});