spiral-modules / php-grpc

:electric_plug: Fast and furious GRPC server for PHP applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Metadata from server

antham opened this issue · comments

Hi, I can't figure out how to send metadatas from server, do you have any clue about that ?

Hi,

sorry about not mentioning about this part in documentation (still waiting to focus on it more).

You can send metadata using the default context and "google.golang.org/grpc/metadata":
https://github.com/spiral/php-grpc/blob/master/proxy_test.go#L108

You can receive it using Context:
https://github.com/spiral/php-grpc/blob/master/tests/GRPC/ContextTest.php

Yes but from the php server you can't do this ?

You should be able to. Check the official client documentation, I can also see metadata in here:
https://github.com/grpc/grpc/blob/master/src/php/lib/Grpc/UnaryCall.php

Ok thanks for your answer I will check that

Hi!
@antham, @wolfy-j, do You have any working example? Can't figure out how to work with the ContextInterface and send metadata from server to client properly. Thank You

Hi @antham @gigi the requested functionality is now implemented: https://github.com/spiral/php-grpc/blob/master/tests/src/Test/TestService.php#L64

$ctx->getValue(GRPC\ResponseHeaders::class)->set('foo', 'bar');

Thanks for this information @wolfgang-braun