Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable default context items derived from request #156

Closed
2 tasks done
voxpelli opened this issue Jun 10, 2023 · 0 comments · Fixed by #157
Closed
2 tasks done

Enable default context items derived from request #156

voxpelli opened this issue Jun 10, 2023 · 0 comments · Fixed by #157

Comments

@voxpelli
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

In #136 / #137 defaultStoreValues was allowed to be a factory, but no parameters was actually sent to it.

I would like it if it was sent the request instance as an argument.

Motivation

Sending request as an argument to the defaultStoreValues factory allows one to easily bootstrap the request context with values derived from the request, which is something I have been doing for eg a logging function.

I will do a PR.

Example

fastify.register(fastifyRequestContextPlugin, { 
  hook: 'preValidation',
  defaultStoreValues: () => ({
    log: request.log.child({ foo: 'bar }),
  }),
});
voxpelli added a commit to voxpelli/fastify-request-context that referenced this issue Jun 10, 2023
voxpelli added a commit to voxpelli/fastify-request-context that referenced this issue Jun 10, 2023
voxpelli added a commit to voxpelli/fastify-request-context that referenced this issue Jun 10, 2023
Fixes fastify#156

Signed-off-by: Pelle Wessman <pelle@kodfabrik.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant