* AnnotateContext adds context information such as metadata from the request. At a minimum, the RemoteAddr is included in the fashion of "X-Forwarded-For", except that the forwarded destination is not another HTTP service but rather a gRPC service. */
(ctx context.Context, mux *ServeMux, req *http.Request, rpcMethodName string, options ...AnnotateContextOption)
| 76 | a gRPC service. |
| 77 | */ |
| 78 | func AnnotateContext(ctx context.Context, mux *ServeMux, req *http.Request, rpcMethodName string, options ...AnnotateContextOption) (context.Context, error) { |
| 79 | ctx, md, err := annotateContext(ctx, mux, req, rpcMethodName, options...) |
| 80 | if err != nil { |
| 81 | return nil, err |
| 82 | } |
| 83 | if md == nil { |
| 84 | return ctx, nil |
| 85 | } |
| 86 | |
| 87 | return metadata.NewOutgoingContext(ctx, md), nil |
| 88 | } |
| 89 | |
| 90 | // AnnotateIncomingContext adds context information such as metadata from the request. |
| 91 | // Attach metadata as incoming context. |