https://github.com/hona/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.
https://github.com/hona/grpc.featureflags
aspnetcore feature-flags grpc grpc-csharp
Last synced: 3 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/hona/grpc.featureflags
- Owner: Hona
- License: mit
- Created: 2024-08-26T01:07:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-26T01:42:50.000Z (over 1 year ago)
- Last Synced: 2025-03-15T21:48:05.207Z (about 1 year ago)
- Topics: aspnetcore, feature-flags, grpc, grpc-csharp
- Language: C#
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
[](https://www.nuget.org/packages/Hona.gRPC.FeatureFlags)
## 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:
```bash
dotnet add package Hona.gRPC.FeatureFlags
```
Modify your dependency injection to include:
```csharp
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
```csharp
[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 PingAsync(PingRequest request, CallContext context = default)
{
return new PingResponse();
}
}
```