diff options
author | lutangar <johan.dufour@gmail.com> | 2021-11-24 14:33:14 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-11-25 09:54:22 +0100 |
commit | 7226e90fdc61a3c6cad5ccab18b6707d55cf0992 (patch) | |
tree | 0bdd7304352b1af2d9ae87439486a138e02d46e8 /support | |
parent | 5098098d96164c93f84ec8419e98fbd83ba8dc71 (diff) | |
download | PeerTube-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')
-rw-r--r-- | support/doc/plugins/guide.md | 14 |
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 | ||
111 | Hooks 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 | ||
114 | async 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 | ||
112 | On client side, these hooks are registered by the `clientScripts` files defined in `package.json`. | 126 | On client side, these hooks are registered by the `clientScripts` files defined in `package.json`. |
113 | All client scripts have scopes so PeerTube client only loads scripts it needs: | 127 | All client scripts have scopes so PeerTube client only loads scripts it needs: |