You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Documentation/grpc-metadata.md
+13-6Lines changed: 13 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -169,7 +169,7 @@ Server side metadata sending and receiving examples are available [here](../exam
169
169
### Receiving metadata
170
170
171
171
To read metadata sent by the client, the server needs to retrieve it from RPC
172
-
context using [FromIncomingContext](https://pkg.go.dev/google.golang.org/grpc/metadata#FromIncomingContext).
172
+
context using [FromIncomingContext][1].
173
173
If it is a unary call, the RPC handler's context can be used.
174
174
For streaming calls, the server needs to get context from the stream.
175
175
@@ -196,8 +196,8 @@ func (s *server) SomeStreamingRPC(stream pb.Service_SomeStreamingRPCServer) erro
196
196
#### Unary call
197
197
198
198
To send header and trailer to client in unary call, the server can call
199
-
[SendHeader](https://godoc.org/google.golang.org/grpc#SendHeader) and [SetTrailer](https://godoc.org/google.golang.org/grpc#SetTrailer)
200
-
functions in module [grpc](https://godoc.org/google.golang.org/grpc).
199
+
[SendHeader][2] and [SetTrailer][3] functions in module
200
+
[grpc](https://godoc.org/google.golang.org/grpc).
201
201
These two functions take a context as the first parameter.
202
202
It should be the RPC handler's context or one derived from it:
203
203
@@ -214,7 +214,9 @@ func (s *server) SomeRPC(ctx context.Context, in *pb.someRequest) (*pb.someRespo
214
214
215
215
#### Streaming call
216
216
217
-
For streaming calls, header and trailer can be sent using function [SendHeader](https://godoc.org/google.golang.org/grpc#SendHeader) and [SetTrailer](https://godoc.org/google.golang.org/grpc#SetTrailer) in interface [ServerStream](https://godoc.org/google.golang.org/grpc#ServerStream):
217
+
For streaming calls, header and trailer can be sent using function
@@ -228,10 +230,15 @@ func (s *server) SomeStreamingRPC(stream pb.Service_SomeStreamingRPCServer) erro
228
230
```
229
231
230
232
Do not use
231
-
[FromOutgoingContext](https://pkg.go.dev/google.golang.org/grpc/metadata#FromOutgoingContext) on the server to write metadata to be sent to the client.
232
-
[FromOutgoingContext](https://pkg.go.dev/google.golang.org/grpc/metadata#FromOutgoingContext) is for client-side use only.
233
+
[FromOutgoingContext][4] on the server to write metadata to be sent to the client.
234
+
[FromOutgoingContext][4] is for client-side use only.
233
235
234
236
## Updating metadata from a server interceptor
235
237
236
238
An example for updating metadata from a server interceptor is
237
239
available [here](../examples/features/metadata_interceptor/server/main.go).
0 commit comments