GrpcEndpoints is a lightweight framework that simplifies gRPC service implementation in .NET by using an endpoint-centric approach. It eliminates boilerplate code through attribute-based mapping and dynamic service generation, allowing developers to focus on implementing business logic rather than repetitive service scaffolding.
- ✅ Eliminate boilerplate service implementation classes
- ✅ Attribute-based mapping of endpoints to gRPC methods
- ✅ Automatic registration of endpoints with dependency injection
- ✅ Dynamic creation of gRPC service implementations
- ✅ Cleaner separation of concerns with endpoint-focused architecture
dotnet add package GrpcEndpoints[GrpcEndpoint(typeof(Greeter.GreeterBase), nameof(Greeter.GreeterBase.SayHello))]
public class SayHello : IGrpcEndpoint<HelloRequest, HelloReply>
{
public Task<HelloReply> ExecuteAsync(HelloRequest request, ServerCallContext context, CancellationToken cancellationToken)
{
return Task.FromResult(new HelloReply
{
Message = $"Hello {request.Name} from GrpcEndpoints!"
});
}
}// Program.cs
builder.Services.AddGrpcEndpoints();// Program.cs
app.MapGrpcEndpoints<Greeter.GreeterBase>();MIT