Skip to content

Commit b75dbe3

Browse files
committed
metadata: fix properly and change to Outgoing
1 parent db5d313 commit b75dbe3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

runtime/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func AnnotateContext(ctx context.Context, req *http.Request) (context.Context, e
9494
if len(pairs) == 0 {
9595
return ctx, nil
9696
}
97-
return metadata.NewIncomingContext(ctx, metadata.Pairs(pairs...)), nil
97+
return metadata.NewOutgoingContext(ctx, metadata.Pairs(pairs...)), nil
9898
}
9999

100100
// ServerMetadata consists of metadata sent from gRPC server.

runtime/context_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestAnnotateContext_WorksWithEmpty(t *testing.T) {
2828
t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err)
2929
return
3030
}
31-
md, ok := metadata.FromIncomingContext(annotated)
31+
md, ok := metadata.FromOutgoingContext(annotated)
3232
if !ok || len(md) != emptyForwardMetaCount {
3333
t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount, md)
3434
}
@@ -50,7 +50,7 @@ func TestAnnotateContext_ForwardsGrpcMetadata(t *testing.T) {
5050
t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err)
5151
return
5252
}
53-
md, ok := metadata.FromIncomingContext(annotated)
53+
md, ok := metadata.FromOutgoingContext(annotated)
5454
if got, want := len(md), emptyForwardMetaCount+4; !ok || got != want {
5555
t.Errorf("metadata items in context = %d want %d: %v", got, want, md)
5656
}
@@ -82,7 +82,7 @@ func TestAnnotateContext_XForwardedFor(t *testing.T) {
8282
t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err)
8383
return
8484
}
85-
md, ok := metadata.FromIncomingContext(annotated)
85+
md, ok := metadata.FromOutgoingContext(annotated)
8686
if !ok || len(md) != emptyForwardMetaCount+1 {
8787
t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount+1, md)
8888
}

0 commit comments

Comments
 (0)