Map adhoc lambda expression to gRPC
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 836
- Avg merge
- 6d 3h
- Merged PRs (30d)
- 7
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.
```cs
MapGrpcUnaryMethod(
this IEndpointRouteBuilder builder,
string serviceName,
string methodName,
UnaryCallHander handler);
```
```cs
routes.MapGrpcUnaryMethod("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.
Contributor guide
Assessment
This issue has not been assessed yet.