MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / AnnotateContext

Function AnnotateContext

runtime/context.go:78–88  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

76a gRPC service.
77*/
78func 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.

Calls 1

annotateContextFunction · 0.85