aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/doc
diff options
context:
space:
mode:
authorlutangar <johan.dufour@gmail.com>2021-11-24 14:33:14 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-11-25 09:54:22 +0100
commit7226e90fdc61a3c6cad5ccab18b6707d55cf0992 (patch)
tree0bdd7304352b1af2d9ae87439486a138e02d46e8 /support/doc
parent5098098d96164c93f84ec8419e98fbd83ba8dc71 (diff)
downloadPeerTube-7226e90fdc61a3c6cad5ccab18b6707d55cf0992.tar.gz
PeerTube-7226e90fdc61a3c6cad5ccab18b6707d55cf0992.tar.zst
PeerTube-7226e90fdc61a3c6cad5ccab18b6707d55cf0992.zip
Add `req` and `res` as controllers hooks parameters
Hooks prefixed by `action:api` now give access the original express req and res. Checkout guide.md for possible usage.
Diffstat (limited to 'support/doc')
-rw-r--r--support/doc/plugins/guide.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index 072c7c6ca..acf4718e4 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -108,6 +108,20 @@ async function register ({
108} 108}
109``` 109```
110 110
111Hooks prefixed by `action:api` also give access the original **express** [Request](http://expressjs.com/en/api.html#req) and [Response](http://expressjs.com/en/api.html#res):
112
113```js
114async function register ({
115 registerHook,
116 peertubeHelpers: { logger }
117}) {
118 registerHook({
119 target: 'action:api.video.updated',
120 handler: ({ req, res }) => logger.debug('original request parameters', { params: req.params })
121 })
122}
123```
124
111 125
112On client side, these hooks are registered by the `clientScripts` files defined in `package.json`. 126On client side, these hooks are registered by the `clientScripts` files defined in `package.json`.
113All client scripts have scopes so PeerTube client only loads scripts it needs: 127All client scripts have scopes so PeerTube client only loads scripts it needs: