-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
feat(microservices): Add grpc metadata to server responce #5143
Conversation
example of usage: import { Metadata } from 'grpc'; @GrpcMethod('Service', 'Method') public method(request: any, metadata: Metadata, sendMetadata: any): any { // 1. nothing to do with request that is empty in this case // 2. may something with metadata from client if needed // 3. send metadata with responce........ const srvMetadata = new Metadata(); srvMetadata.add('Set-Cookie', 'yummy_cookie=choco'); sendMetadata(srvMetadata); return 'Hello World!!!'; }
Pull Request Test Coverage Report for Build d8106f42-dec7-49a5-bd41-01fe82ee1392
💛 - Coveralls |
f8a525f
to
b766c74
Compare
example of usage: import { Metadata } from 'grpc'; @GrpcMethod('Service', 'Method') public method(request: any, metadata: Metadata, call: any): any { // 1. nothing to do with request that is empty in this case // 2. may something with metadata from client if needed // 3. send metadata with responce........ const srvMetadata = new Metadata(); srvMetadata.add('Set-Cookie', 'yummy_cookie=choco'); call.sendMetadata(srvMetadata); return 'Hello World!!!'; }
Would you like to create a PR to the docs with this feature? |
Sure, I will do it |
|
@AlexDaSoul Is there a way to get these metadata from the response on the client side when using nestjs grpc client ? When I look into the code, it seems not, but maybe I'm missing something ? |
There is no direct option, but we can get metadata using the event 'metadata' of client
|
Ok. Thanks |
#5098 PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Cannot send metadata from @GrpcMethod
Issue Number: #1897
What is the new behavior?
import { Metadata } from 'grpc';
Does this PR introduce a breaking change?
Other information