Skip to content

Commit c356143

Browse files
committed
Make hooks accessible in the same fastify context, fixes #702
1 parent 6aa0de0 commit c356143

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sdk_contrib/fastify/lib/plugin.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
// @ts-check
2+
const fp = require('fastify-plugin').default;
23
const configureAWSXRaySync = require('./private/configure-aws-x-ray-sync');
34
const onRequestHook = require('./hooks/on-request.hook');
45
const onResponseHook = require('./hooks/on-response.hook');
56
const onErrorHook = require('./hooks/on-error.hook');
67

78
/** @type {import('fastify').FastifyPluginAsync} */
8-
const xRayFastifyPlugin = async (fastify, opts) => {
9+
const xRayFastifyPlugin = fp(async (fastify, opts) => {
910
configureAWSXRaySync(fastify, opts);
1011

1112
fastify.decorateRequest('segment', null);
1213
fastify
1314
.addHook('onRequest', onRequestHook)
1415
.addHook('onResponse', onResponseHook)
1516
.addHook('onError', onErrorHook);
16-
};
17+
});
1718

1819
module.exports = xRayFastifyPlugin;
1920

0 commit comments

Comments
 (0)