docs: fix minor issues in middleware docs (#3436)

This commit is contained in:
fry69
2025-09-15 12:20:48 +02:00
committed by GitHub
parent b4bb004753
commit 016f94e28e
+6 -6
View File
@@ -39,7 +39,7 @@ excellent way to make http-related logic reusable on the server.
Use the `define.middleware()` helper to get typings out of the box:
```ts middleware/my-middleware.ts
import { define } from "./utils.ts";
import { define } from "../utils.ts";
const middleware = define.middleware(async (ctx) => {
console.log("my middleware");
@@ -52,7 +52,7 @@ const middleware = define.middleware(async (ctx) => {
Fresh ships with the following middlewares built-in:
- [cors()](/docs/plugins/cors) - Set CORS HTTP headers
- [csrf()](/docs/plugins/cors) - Set CSRF HTTP headers
- [csrf()](/docs/plugins/csrf) - Set CSRF HTTP headers
- [trailingSlash()](/docs/plugins/trailing-slashes) - Enforce trailing slashes
## Filesystem-based middlewares
@@ -60,8 +60,8 @@ Fresh ships with the following middlewares built-in:
With file system based routing you can define a middleware in a `_middleware.ts`
file inside the `routes/` folder or any of it's subfolders.
```ts routes/foo/_middleware.ts
import { define } from "./utils.ts";
```ts routes/_middleware.ts
import { define } from "../utils.ts";
export default define.middleware(async (ctx) => {
console.log("my middleware");
@@ -71,8 +71,8 @@ export default define.middleware(async (ctx) => {
You can also export an array of middlewares:
```ts routes/foo/_middleware.ts
import { define } from "./utils.ts";
```ts routes/_middleware.ts
import { define } from "../utils.ts";
const middleware1 = define.middleware(async (ctx) => {
console.log("A");