You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/Grpc.AspNetCore.Server/GrpcServiceExtensions.cs
+11-2
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
#region Copyright notice and license
1
+
#region Copyright notice and license
2
2
3
3
// Copyright 2019 The gRPC Authors
4
4
//
@@ -61,7 +61,16 @@ public static IGrpcServerBuilder AddGrpc(this IServiceCollection services)
61
61
thrownewArgumentNullException(nameof(services));
62
62
}
63
63
64
-
services.AddRouting();
64
+
services.AddRouting(options =>
65
+
{
66
+
// Unimplemented constraint is added to the route as an inline constraint to avoid RoutePatternFactory.Parse overload that includes parameter policies. That overload infers strings as regex constraints, which brings in
67
+
// the regex engine when publishing trimmed or AOT apps. This change reduces Native AOT gRPC server app size by about 1 MB.
endpointConventionBuilders.Add(CreateUnimplementedEndpoint(endpointRouteBuilder,serviceName+"/{unimplementedMethod}",$"Unimplemented method for {serviceName}",serverCallHandlerFactory.CreateUnimplementedMethod()));
145
+
endpointConventionBuilders.Add(CreateUnimplementedEndpoint(endpointRouteBuilder,$"{serviceName}/{{unimplementedMethod:{GrpcServerConstants.GrpcUnimplementedConstraintPrefix}}}",$"Unimplemented method for {serviceName}",serverCallHandlerFactory.CreateUnimplementedMethod()));
0 commit comments