SetTrailer sets the trailer metadata that will be sent when an RPC returns. When called more than once, all the provided metadata will be merged. The error returned is compatible with the status package. However, the status code will often not match the RPC status as seen by the client application
(ctx context.Context, md metadata.MD)
| 2190 | // status code will often not match the RPC status as seen by the client |
| 2191 | // application, and therefore, should not be relied upon for this purpose. |
| 2192 | func SetTrailer(ctx context.Context, md metadata.MD) error { |
| 2193 | if md.Len() == 0 { |
| 2194 | return nil |
| 2195 | } |
| 2196 | stream := ServerTransportStreamFromContext(ctx) |
| 2197 | if stream == nil { |
| 2198 | return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx) |
| 2199 | } |
| 2200 | return stream.SetTrailer(md) |
| 2201 | } |
| 2202 | |
| 2203 | // Method returns the method string for the server context. The returned |
| 2204 | // string is in the format of "/service/method". |