Skip to content

Commit bfa5c7d

Browse files
Fix mistake in Middleware documentation (#2820) (#2827)
Co-authored-by: meganelacheny <[email protected]>
1 parent e33b3d0 commit bfa5c7d

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

docusaurus/docs/cms/backend-customization/middlewares.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,27 +194,27 @@ Proper implementation largely depends on your project's needs and custom code, b
194194
};
195195
```
196196

197-
7. Ensure the middleware is configured to apply on some routes. In the `config` object found in the `src/api/[your-api–name]/routes/[your-content-type-name].js` file, define the methods (`create`, `read`, `update`, `delete`) for which you would like the middleware to apply, and declare the `isOwner` middleware for these routes.<br /><br />For instance, if you wish to allow GET (i.e., `read` method) and POST (i.e., `create` method) requests to any user for the `restaurant` content-type in the `restaurant` API, but would like to restrict PUT (i.e., `update` method) and DELETE requests only to the user who created the entry, you could use the following code in the `src/api/restaurant/routes/restaurant.js` file:
197+
7. Ensure the middleware is configured to apply on some routes. In the `config` object found in the `src/api/[your-api–name]/routes/[your-content-type-name].js` file, define the action keys (`find`, `findOne`, `create`, `update`, `delete`, etc.) for which you would like the middleware to apply, and declare the `isOwner` middleware for these routes.<br /><br />For instance, if you wish to allow GET requests (mapping to the `find` and `findOne` actions) and POST requests (i.e., the `create` action) to any user for the `restaurant` content-type in the `restaurant` API, but would like to restrict PUT (i.e., `update` action) and DELETE requests only to the user who created the entry, you could use the following code in the `src/api/restaurant/routes/restaurant.js` file:
198198

199-
```js title="src/api/restaurant/routes/restaurant.js"
199+
```js title="src/api/restaurant/routes/restaurant.js"
200200

201-
/**
202-
* restaurant router
203-
*/
201+
/**
202+
* restaurant router
203+
*/
204204

205-
const { createCoreRouter } = require("@strapi/strapi").factories;
205+
const { createCoreRouter } = require("@strapi/strapi").factories;
206206

207-
module.exports = createCoreRouter("api::restaurant.restaurant", {
208-
config: {
209-
update: {
210-
middlewares: ["api::restaurant.is-owner"],
211-
},
212-
delete: {
213-
middlewares: ["api::restaurant.is-owner"],
214-
},
207+
module.exports = createCoreRouter("api::restaurant.restaurant", {
208+
config: {
209+
update: {
210+
middlewares: ["api::restaurant.is-owner"],
215211
},
216-
});
217-
```
212+
delete: {
213+
middlewares: ["api::restaurant.is-owner"],
214+
},
215+
},
216+
});
217+
```
218218

219219
:::info
220220
You can find more information about route middlewares in the [routes documentation](/cms/backend-customization/routes).

0 commit comments

Comments
 (0)