Skip to content

Commit

Permalink
bugfix: reflect upstream api change. (#359)
Browse files Browse the repository at this point in the history
metadata.NewContext now is a synonym for metadata.NewOutgoingContext. Call NewIncomingContext instead.
  • Loading branch information
tmc authored and achew22 committed Apr 17, 2017
1 parent 2ad234c commit eaa3c30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion runtime/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func AnnotateContext(ctx context.Context, req *http.Request) (context.Context, e
if len(pairs) == 0 {
return ctx, nil
}
return metadata.NewContext(ctx, metadata.Pairs(pairs...)), nil
return metadata.NewIncomingContext(ctx, metadata.Pairs(pairs...)), nil
}

// ServerMetadata consists of metadata sent from gRPC server.
Expand Down
6 changes: 3 additions & 3 deletions runtime/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestAnnotateContext_WorksWithEmpty(t *testing.T) {
t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err)
return
}
md, ok := metadata.FromContext(annotated)
md, ok := metadata.FromIncomingContext(annotated)
if !ok || len(md) != emptyForwardMetaCount {
t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount, md)
}
Expand All @@ -50,7 +50,7 @@ func TestAnnotateContext_ForwardsGrpcMetadata(t *testing.T) {
t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err)
return
}
md, ok := metadata.FromContext(annotated)
md, ok := metadata.FromIncomingContext(annotated)
if got, want := len(md), emptyForwardMetaCount+4; !ok || got != want {
t.Errorf("metadata items in context = %d want %d: %v", got, want, md)
}
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestAnnotateContext_XForwardedFor(t *testing.T) {
t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err)
return
}
md, ok := metadata.FromContext(annotated)
md, ok := metadata.FromIncomingContext(annotated)
if !ok || len(md) != emptyForwardMetaCount+1 {
t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount+1, md)
}
Expand Down

0 comments on commit eaa3c30

Please sign in to comment.