grpc / grpc/grpc-node

Contextual information from interceptors to request handlers

Open
#2,871 4 comments 0 reactions 0 assignees View on GitHub
package: @grpc/grpc-js
Dominant language
TypeScript
Stars
4.8k
Forks
716
Avg merge
2d 3h
Merged PRs (30d)
10

Description

### Is your feature request related to a problem? Please describe.

This might already be possible but I haven't found a way to do it. Please advice.

What I would like to do is to pass additional, per-request information from the interceptors to the request handers. For example, I've an auth interceptor which validates the authentication params and I would like to attach some information (e.g. the user id) that's latter consumed by the request handler.

### Describe the solution you'd like

A way to attach contextual information to requests.

### Describe alternatives you've considered

- I can think of moving some of the logic outside of the interceptor into another module/function and call that from the request handlers. While it would work, it's not as clean as adding the data I need in the interceptors.
- I could also whatever information I want to the request metadata. I don't like this one so much because the boundaries between client metadata and my metadata are blurred. ~~I could use a symbol to avoid clashes though~~ (can't pass a symbol as metadata keys must be strings). And metadata only allows buffers or strings as values and I'd like to be possible to pass an object.

### Additional context

This is possible in many other http api frameworks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.