mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Add ability for plugins to add custom routes
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
- [Settings](#settings)
|
||||
- [Storage](#storage)
|
||||
- [Update video constants](#update-video-constants)
|
||||
- [Add custom routes](#add-custom-routes)
|
||||
- [Client helpers (themes & plugins)](#client-helpers-themes--plugins)
|
||||
- [Plugin static route](#plugin-static-route)
|
||||
- [Translate](#translate)
|
||||
@@ -71,7 +72,9 @@ async function register ({
|
||||
storageManager,
|
||||
videoCategoryManager,
|
||||
videoLicenceManager,
|
||||
videoLanguageManager
|
||||
videoLanguageManager,
|
||||
peertubeHelpers,
|
||||
getRouter
|
||||
}) {
|
||||
registerHook({
|
||||
target: 'action:application.listening',
|
||||
@@ -178,6 +181,20 @@ videoLicenceManager.addLicence(42, 'Best licence')
|
||||
videoLicenceManager.deleteLicence(7) // Public domain
|
||||
```
|
||||
|
||||
#### Add custom routes
|
||||
|
||||
You can create custom routes using an [express Router](https://expressjs.com/en/4x/api.html#router) for your plugin:
|
||||
|
||||
```js
|
||||
const router = getRouter()
|
||||
router.get('/ping', (req, res) => res.json({ message: 'pong' }))
|
||||
```
|
||||
|
||||
The `ping` route can be accessed using:
|
||||
* `/plugins/:pluginName/:pluginVersion/router/ping`
|
||||
* Or `/plugins/:pluginName/router/ping`
|
||||
|
||||
|
||||
### Client helpers (themes & plugins)
|
||||
|
||||
### Plugin static route
|
||||
|
||||
Reference in New Issue
Block a user