muench-develops.FeatureToggler 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package muench-develops.FeatureToggler --version 1.0.0                
NuGet\Install-Package muench-develops.FeatureToggler -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="muench-develops.FeatureToggler" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add muench-develops.FeatureToggler --version 1.0.0                
#r "nuget: muench-develops.FeatureToggler, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install muench-develops.FeatureToggler as a Cake Addin
#addin nuget:?package=muench-develops.FeatureToggler&version=1.0.0

// Install muench-develops.FeatureToggler as a Cake Tool
#tool nuget:?package=muench-develops.FeatureToggler&version=1.0.0                

muench-develops.FeatureToggler

muench-develops.FeatureToggler is a lightweight and extensible library for managing feature flags in .NET applications. It allows you to dynamically enable or disable features using multiple providers.

Features

  • Multiple Providers: In-Memory, JSON, Environment Variables.
  • ASP.NET Core Integration: Middleware for feature-based request handling.
  • Extensible: Easily add custom providers.
  • Thread-Safe: Safe for concurrent updates and queries.

Installation

Install via NuGet:

dotnet add package muench-develops.FeatureToggler

Quick Start

1. Register Feature Flags

builder.Services.AddFeatureFlags(
    new InMemoryFeatureFlagProvider(
        new[]
        {
            new FeatureFlag("EnableNewUI", true, "Enables the new UI"),
            new FeatureFlag("BetaFeature", false, "Beta feature toggle")
        })
);
2a. Use Middleware

Execute actions based on feature flag states:

app.UseFeatureFlag("EnableNewUI",
    onEnabled: () => Console.WriteLine("New UI is enabled!"),
    onDisabled: () => Console.WriteLine("New UI is disabled!"));
2b. Use Minimal API
app.MapGet("/", (FeatureFlagManager manaer) => manager.IsEnabled("EnableNewUI")
        ? Results.Ok("Welcome to the new UI!")
        : Results.Ok("Welcome to the old UI!"));
3. Query Flags

Check or update feature flags dynamically:

var manager = app.Services.GetRequiredService<FeatureFlagManager>();

if (manager.IsEnabled("EnableNewUI"))
{
    Console.WriteLine("New UI is enabled!");
}

License

This project is licensed under the Apache License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 99 12/21/2024
1.0.1 101 12/21/2024
1.0.0 95 12/21/2024