Open
Description
Today gRPC responses are always mapped to a service. What about adding some additional startup extension methods for mapping a lambda expression to a gRPC endpoint.
MapGrpcUnaryMethod<TRequest, TResponse>(
this IEndpointRouteBuilder builder,
string serviceName,
string methodName,
UnaryCallHander<TRequest, TResponse> handler);
routes.MapGrpcUnaryMethod<HelloRequest, HelloReply>("Greet.Greeter/SayHello", async (request, context) =>
{
return new HelloReply("Hello " + request.Message);
});
One issue to solve in the example above is serialization of the request and reply. That is defined on Grpc.Core's Method type, and with code-gen a marshaller is created over the top of a protobuf IMessage for the user. Need to think of a nice looking way to give that info to MapGrpcXXXMethod.