Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React to changes in the latest .NET Core SDK #172

Merged
merged 2 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.0.100-preview4-010737"
"version": "3.0.100-preview4-010898"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public void GlobalSetup()

_httpContext = new DefaultHttpContext();
_httpContext.RequestServices = _requestServices;
_httpContext.Request.BodyPipe = _requestPipe;
_httpContext.Request.BodyReader = _requestPipe;
_httpContext.Request.ContentType = GrpcProtocolConstants.GrpcContentType;
_httpContext.Response.BodyPipe = new TestPipeWriter();
_httpContext.Response.BodyWriter = new TestPipeWriter();

_httpContext.Features.Set<IHttpResponseTrailersFeature>(new TestHttpResponseTrailersFeature
{
Expand Down
11 changes: 9 additions & 2 deletions src/Grpc.AspNetCore.Server/Internal/GrpcServiceBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ private void AddMethodCore(IMethod method, RequestDelegate requestDelegate, List
resolvedMetadata.Add(method);
resolvedMetadata.AddRange(metadata);

EndpointConventionBuilders.Add(_builder.MapPost(method.FullName, $"gRPC - {method.FullName}", requestDelegate, resolvedMetadata.ToArray()));
var endpointBuilder = _builder
.MapPost(method.FullName, requestDelegate)
.WithDisplayName($"gRPC - {method.FullName}")
.WithMetadata(resolvedMetadata.ToArray());

EndpointConventionBuilders.Add(endpointBuilder);
}

internal void CreateUnimplementedEndpoints()
Expand Down Expand Up @@ -124,7 +129,9 @@ internal void CreateUnimplementedEndpoints()
private void CreateUnimplementedEndpoint(string pattern, string displayName, RequestDelegate requestDelegate)
{
var routePattern = RoutePatternFactory.Parse(pattern, defaults: null, new { contentType = GrpcContentTypeConstraint.Instance });
_builder.Map(routePattern, displayName, requestDelegate, new HttpMethodMetadata(new[] { "POST" }));
_builder.Map(routePattern, requestDelegate)
.WithDisplayName(displayName)
.WithMetadata(new HttpMethodMetadata(new[] { "POST" }));
}

private class GrpcContentTypeConstraint : IRouteConstraint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
using Grpc.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Logging.Testing;
Expand Down Expand Up @@ -265,7 +264,7 @@ public void ConsolidateTrailers_Base64EncodesBinaryTrailers(string trailerName)

private class TestHttpResponseTrailersFeature : IHttpResponseTrailersFeature
{
public IHeaderDictionary Trailers { get; set; } = new HttpResponseTrailers();
public IHeaderDictionary Trailers { get; set; } = new HeaderDictionary();
}

private static readonly ISystemClock TestClock = new TestSystemClock(new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc));
Expand Down
3 changes: 1 addition & 2 deletions testassets/FunctionalTestsWebsite/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.IdentityModel.Tokens;
Expand Down Expand Up @@ -100,7 +99,7 @@ public void Configure(IApplicationBuilder app)
{
context.Features.Set<IHttpResponseTrailersFeature>(new TestHttpResponseTrailersFeature
{
Trailers = new HttpResponseTrailers()
Trailers = new HeaderDictionary()
});
}

Expand Down