From 4862152936685f8bb427e2fc38c57a9e277cf3cf Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 8 Sep 2022 11:37:52 +0200 Subject: [PATCH] docs: add stacked middleware docs --- docs/concepts/middleware.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/concepts/middleware.md b/docs/concepts/middleware.md index ee4ab97c..473e7061 100644 --- a/docs/concepts/middleware.md +++ b/docs/concepts/middleware.md @@ -71,3 +71,22 @@ For a request to `/admin/signin` the request flows like this: 2. Calling `ctx.next()` will invoke the `routes/admin/_middleware.ts` middleware. 3. Calling `ctx.next()` will invoke the `routes/admin/signin.ts` handler. + +A single middleware file can also define multiple middlewares (all for the same +route) by exporting an array of handlers instead of a single handler. For +example: + +```ts +// routes/_middleware.ts + +export const handler = [ + async function middleware1(req, ctx) { + // do something + return ctx.next(); + }, + async function middleware2(req, ctx) { + // do something + return ctx.next(); + }, +]; +```