Skip to content

Commit

Permalink
Add a small callout for good practices re. controllers vs. middlewares (
Browse files Browse the repository at this point in the history
  • Loading branch information
pwizla authored Feb 16, 2024
1 parent c57a0f0 commit ccd529c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docusaurus/docs/dev-docs/backend-customization/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ In most cases, the controllers will contain the bulk of a project's business log
<em><figcaption style={captionStyle}>The diagram represents a simplified version of how a request travels through the Strapi back end, with controllers highlighted. The backend customization introduction page includes a complete, <a href="/dev-docs/backend-customization#interactive-diagram">interactive diagram</a>.</figcaption></em>
</figure>

<br/>

:::caution
Before deciding to customize core controllers, please consider creating custom route middlewares (see [routes documentation](/dev-docs/backend-customization/routes)).
:::

## Implementation

Controllers can be [generated or added manually](#adding-a-new-controller). Strapi provides a `createCoreController` factory function that automatically generates core controllers and allows building custom ones or [extend or replace the generated controllers](#extending-core-controllers).
Expand Down Expand Up @@ -422,6 +428,8 @@ An action from a core controller can be replaced entirely by [creating a custom
When extending a core controller, you do not need to re-implement any sanitization as it will already be handled by the core controller you are extending. Where possible it's strongly recommended to extend the core controller instead of creating a custom controller.
:::



<details>
<summary>Collection type examples</summary>

Expand Down

0 comments on commit ccd529c

Please sign in to comment.