Skip to content

Map adhoc lambda expression to gRPC #111

Open
@JamesNK

Description

@JamesNK

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs designThe issue requires design work to be completed before implementation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions