-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[v4] Backend customizations introduction #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/strapijs/documentation/3WDGbAjasL1g2w8BQi2ocm77kuss |
|
||
## Requests | ||
|
||
As Strapi runs an HTTP server, it receives requests, handled by [routes](#routes). These requests can come from API calls (e.g. via a client application) or from the Strapi's admin panel and plugins. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this more explicit, i.e it receives requests that are forwarded to the controllers that handle them by the routes.
or is that not necessary in this context?
As Strapi runs an HTTP server, it receives requests, handled by [routes](#routes). These requests can come from API calls (e.g. via a client application) or from the Strapi's admin panel and plugins. | |
As Strapi runs an HTTP server, it receives requests, handled by [routes](#routes). These requests can come from API calls (e.g. via a client application) or from the Strapi's admin panel and plugins. |
|
||
- the request itself is accessible through `ctx.request` and is available to [controllers](#controllers) and [policies](#policies), | ||
- the body of the request is passed as `ctx.request.body`, | ||
- and the files are passed as `ctx.request.files`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should expand this to include some of our custom objects here like ctx.request.route
|
||
## Routes | ||
|
||
Requests can be handled on any URL by adding [routes](/developer-docs/latest/development/backend-customization/routes.md) to Strapi. Using routes is the first step towards creating custom JSON APIs to be used later on in the client application. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requests can be handled on any URL by adding [routes](/developer-docs/latest/development/backend-customization/routes.md) to Strapi. Using routes is the first step towards creating custom JSON APIs to be used later on in the client application. | |
Requests can be handled on any URL by adding [routes](/developer-docs/latest/development/backend-customization/routes.md) to Strapi. Using routes is the first step towards creating custom REST APIs to be used later on in the client application. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounded weird, indeed, but it was actually written like this ('JSON') by @alexandrebodin in the document he sent me. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured it was okay in order to create the distinction, "JSON APIs" for both REST and GraphQL? 🤔
|
||
As a developer, you can manually add policies, and they can also be added by the admin panel or by plugins. | ||
|
||
## Middlewares |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably specify there are global middlewares (ran on every request) or route middlewares (which are only ran when the specific route is called).
In v3 we only had global middlewares and v3 policies functioned as route middlewares but that's changed with the new policy system in v4
docs/developer-docs/latest/development/backend-customization.md
Outdated
Show resolved
Hide resolved
Co-authored-by: DMehaffy <derrickmehaffy@gmail.com>
Thank you for your very valuable feedback, everyone! I'm closing this PR as, after discussing its content and structure with Mégane, we will do it another way:
|
What does it do?
Adds a contextual introduction for Backend customization.
Will be used as a landing page (if needed for SEO/redirections).
Note: The various concepts (routes, controllers, policies, middlewares…), now split in separate files, will be updated in upcoming PRs.