chore: release 1.3.0 (#1460)

This commit is contained in:
Marvin Hagemeister
2023-07-18 18:09:13 +02:00
committed by GitHub
parent b3c22384e0
commit 2575ca5cad
13 changed files with 98 additions and 631 deletions
+21 -1
View File
@@ -10,7 +10,10 @@ use-cases for this are logging, authentication, and performance monitoring.
Each middleware gets passed a `next` function in the context argument that is
used to trigger child handlers. The `ctx` also has a `state` property that can
be used to pass arbitrary data to downstream (or upstream) handlers.
be used to pass arbitrary data to downstream (or upstream) handlers. This
`state` is included in `PageProps` by default, which is available to both the
special [\_app](/docs/concepts/app-wrapper.md) wrapper and normal
[routes](/docs/concepts/routes.md).
```ts
// routes/_middleware.ts
@@ -95,6 +98,23 @@ export const handler = [
];
```
It should be noted that `middleware` has access to route parameters. If you're
running a fictitious `routes/[tenant]/admin/_middleware.ts` like this:
```ts
import { MiddlewareHandlerContext } from "$fresh/server.ts";
export async function handler(_req: Request, ctx: MiddlewareHandlerContext) {
const currentTenant = ctx.params.tenant;
//do something with the tenant
const resp = await ctx.next();
return resp;
}
```
and the request is to `mysaas.com/acme/admin/`, then `currentTenant` will have
the value of `acme` in your middleware.
## Middleware Destination
To set the stage for this section, `MiddlewareHandlerContext` looks like this: