aboutsummaryrefslogtreecommitdiffhomepage
path: root/support
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-10 15:07:54 +0200
committerChocobozzz <me@florianbigard.com>2020-04-10 15:23:25 +0200
commit5e2b2e2775421cd98286d6e2f75cf38aae7a212c (patch)
treed92e32824d83cecbe5e90206738f393b47e55754 /support
parent9afa0901f11c321e071c42ba3c814a3af4843c55 (diff)
downloadPeerTube-5e2b2e2775421cd98286d6e2f75cf38aae7a212c.tar.gz
PeerTube-5e2b2e2775421cd98286d6e2f75cf38aae7a212c.tar.zst
PeerTube-5e2b2e2775421cd98286d6e2f75cf38aae7a212c.zip
Add ability for plugins to add custom routes
Diffstat (limited to 'support')
-rw-r--r--support/doc/plugins/guide.md19
1 files changed, 18 insertions, 1 deletions
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index 8e720e94b..bdc9d2ad8 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -12,6 +12,7 @@
12 - [Settings](#settings) 12 - [Settings](#settings)
13 - [Storage](#storage) 13 - [Storage](#storage)
14 - [Update video constants](#update-video-constants) 14 - [Update video constants](#update-video-constants)
15 - [Add custom routes](#add-custom-routes)
15 - [Client helpers (themes & plugins)](#client-helpers-themes--plugins) 16 - [Client helpers (themes & plugins)](#client-helpers-themes--plugins)
16 - [Plugin static route](#plugin-static-route) 17 - [Plugin static route](#plugin-static-route)
17 - [Translate](#translate) 18 - [Translate](#translate)
@@ -71,7 +72,9 @@ async function register ({
71 storageManager, 72 storageManager,
72 videoCategoryManager, 73 videoCategoryManager,
73 videoLicenceManager, 74 videoLicenceManager,
74 videoLanguageManager 75 videoLanguageManager,
76 peertubeHelpers,
77 getRouter
75}) { 78}) {
76 registerHook({ 79 registerHook({
77 target: 'action:application.listening', 80 target: 'action:application.listening',
@@ -178,6 +181,20 @@ videoLicenceManager.addLicence(42, 'Best licence')
178videoLicenceManager.deleteLicence(7) // Public domain 181videoLicenceManager.deleteLicence(7) // Public domain
179``` 182```
180 183
184#### Add custom routes
185
186You can create custom routes using an [express Router](https://expressjs.com/en/4x/api.html#router) for your plugin:
187
188```js
189const router = getRouter()
190router.get('/ping', (req, res) => res.json({ message: 'pong' }))
191```
192
193The `ping` route can be accessed using:
194 * `/plugins/:pluginName/:pluginVersion/router/ping`
195 * Or `/plugins/:pluginName/router/ping`
196
197
181### Client helpers (themes & plugins) 198### Client helpers (themes & plugins)
182 199
183### Plugin static route 200### Plugin static route