Skip to content

Commit

Permalink
Update server-api.md (#1860)
Browse files Browse the repository at this point in the history
Add example on combining admin and content-api routes
  • Loading branch information
MindDesign authored Oct 2, 2023
1 parent f99de20 commit 03899c5
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docusaurus/docs/dev-docs/api/plugins/server-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,50 @@ module.exports = [
];
```

It is also possible to combine both admin and content type routes if you need different policies on these. Here is an example on how this can be achieved

```js title="path: ./src/plugins/my-plugin/server/routes/index.js"

module.exports = {
admin: require('./admin'),
'content-api': require('./content-api'),
};
```

```js title="path: ./src/plugins/my-plugin/server/routes/admin/index.js"

module.exports = {
type: 'admin',
routes: [{
method: 'GET',
path: '/model',
handler: 'controllerName.action',
config: {
policies: ['policyName'],
},
}],
};
```


```js title="path: ./src/plugins/my-plugin/server/routes/content-api/index.js"

module.exports = {
type: 'content-api',
routes: [{
method: 'GET',
path: '/model',
handler: 'controllerName.action',
config: {
policies: ['differentPolicyName'],
},
}],
};
```




### Controllers

An object with the [controllers](/dev-docs/backend-customization/controllers) the plugin provides.
Expand Down

1 comment on commit 03899c5

@vercel
Copy link

@vercel vercel bot commented on 03899c5 Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

documentation – ./

documentation-strapijs.vercel.app
documentation-git-main-strapijs.vercel.app
docs-vercel-v4.strapi.io

Please sign in to comment.