doc: Rename _req used to req (#2349)

Where other documents use req, they use the name req instead of _req


https://github.com/denoland/fresh/blob/b7281792a0a5b2674f659514b1e58116fabd6460/docs/latest/concepts/middleware.md?plain=1#L153
This commit is contained in:
narumincho
2024-03-21 09:32:59 +00:00
committed by GitHub
parent 240252fdb4
commit 407e4379df
2 changed files with 7 additions and 7 deletions
+4 -4
View File
@@ -47,18 +47,18 @@ deal with "preflight requests". Let's imagine you're trying to support a
```ts routes/_middleware.ts
import { FreshContext } from "$fresh/server.ts";
export async function handler(_req: Request, ctx: FreshContext) {
if (_req.method == "OPTIONS") {
export async function handler(req: Request, ctx: FreshContext) {
if (req.method == "OPTIONS") {
const resp = new Response(null, {
status: 204,
});
const origin = _req.headers.get("Origin") || "*";
const origin = req.headers.get("Origin") || "*";
const headers = resp.headers;
headers.set("Access-Control-Allow-Origin", origin);
headers.set("Access-Control-Allow-Methods", "DELETE");
return resp;
}
const origin = _req.headers.get("Origin") || "*";
const origin = req.headers.get("Origin") || "*";
const resp = await ctx.next();
const headers = resp.headers;
+3 -3
View File
@@ -1,13 +1,13 @@
import { FreshContext, MiddlewareHandler } from "$fresh/server.ts";
// cors middleware
async function corsHandler(_req: Request, ctx: FreshContext) {
if (_req.method == "OPTIONS") {
async function corsHandler(req: Request, ctx: FreshContext) {
if (req.method == "OPTIONS") {
return new Response(null, {
status: 204,
});
}
const origin = _req.headers.get("Origin") || "*";
const origin = req.headers.get("Origin") || "*";
const resp = await ctx.next();
const headers = resp.headers;