Skip to content

Support for Microsoft.FeatureManagement within ASP.NET Core gRPC applications. Example being, feature flags in Azure App Config, with the same attribute syntax [FeatureGate] used on controllers, but working for gRPC.

License

Notifications You must be signed in to change notification settings

Hona/gRPC.FeatureFlags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC.FeatureFlags

Support for Microsoft.FeatureManagement within ASP.NET Core gRPC applications. Example being, feature flags in Azure App Config, with the same attribute syntax [FeatureGate] used on controllers, but working for gRPC.

NuGet Version

Pre-requisites

Assuming you are using code first gRPC services for ASP.NET Core

e.g. packages:

  • protobuf-net.Grpc.AspNetCore
  • Grpc.AspNetCore.Web

Usage

Add the package to your project:

dotnet add package Hona.gRPC.FeatureFlags

Modify your dependency injection to include:

using Hona.gRPC.FeatureFlags; // 👈 New code
...
services.AddCodeFirstGrpc(config =>
{
    ...
    config.UseFeatureFlags(); // 👈 New code
});

Now you can add the attribute in one of 3 places

  • On the Request model
  • On the Service
  • On the method
[FeatureGate("Ping")] // 👈 This works
public class PingRequest { }

public class PingResponse { }

[FeatureGate("Ping")] // 👈 This works
public class MyService : IMyService
{
    // 👇 My preferred location, or on the service
    [FeatureGate("Ping")] // 👈 This works
    [Authorize] // This already works, its nice to have both side by side
    public async Task<PingResponse> PingAsync(PingRequest request, CallContext context = default)
    {
        return new PingResponse();
    }
}

About

Support for Microsoft.FeatureManagement within ASP.NET Core gRPC applications. Example being, feature flags in Azure App Config, with the same attribute syntax [FeatureGate] used on controllers, but working for gRPC.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages