Add policies information to routing and link controllers to routing docs (#8445)

Signed-off-by: Derrick Mehaffy <derrickmehaffy@gmail.com>
This commit is contained in:
DMehaffy 2020-10-26 09:40:30 -07:00 committed by GitHub
parent ef710166df
commit c86d5d274e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -316,7 +316,7 @@ Every action receives a `context` (`ctx`) object as first parameter containing t
### Example
In this example, we are defining a specific route in `./api/hello/config/routes.json` that takes `Hello.index` as handler.
In this example, we are defining a specific route in `./api/hello/config/routes.json` that takes `Hello.index` as handler. For more information on routing, please see the [Routing documentation](./routing.md)
It means that every time a request `GET /hello` is sent to the server, Strapi will call the `index` action in the `Hello.js` controller.
Our `index` action will return `Hello World!`. You can also return a JSON object.
@ -329,7 +329,10 @@ Our `index` action will return `Hello World!`. You can also return a JSON object
{
"method": "GET",
"path": "/hello",
"handler": "Hello.index"
"handler": "Hello.index",
"config": {
"policies": []
}
}
]
}

View File

@ -49,6 +49,10 @@ You have to edit the `routes.json` file in one of your APIs folders (`./api/**/c
- `config`
- `policies` (array): Array of policy names or paths ([see more](./policies.md))
::: tip
You can exclude the entire `config` object if you do not want the route to be checked by the [Users & Permissions plugin](../plugins/users-permissions.md).
:::
## Dynamic parameters
The router used by Strapi allows you to create dynamic routes where you can use parameters and simple regular expressions. These parameters will be exposed in the `ctx.params` object. For more details, please refer to the [PathToRegex](https://github.com/pillarjs/path-to-regexp) documentation.