Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dianper/feature-toggle
Custom feature flag using Microsoft.FeatureManagement
https://github.com/dianper/feature-toggle
c-sharp cookies feature-flags feature-toggle featuremanagement headers microsoft querystring
Last synced: about 1 month ago
JSON representation
Custom feature flag using Microsoft.FeatureManagement
- Host: GitHub
- URL: https://github.com/dianper/feature-toggle
- Owner: dianper
- License: mit
- Created: 2019-08-02T13:49:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-08T11:54:58.000Z (almost 5 years ago)
- Last Synced: 2024-11-08T02:03:29.454Z (3 months ago)
- Topics: c-sharp, cookies, feature-flags, feature-toggle, featuremanagement, headers, microsoft, querystring
- Language: C#
- Homepage:
- Size: 40 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![CircleCI](https://circleci.com/gh/dianper/feature-toggle.svg?style=shield)](https://circleci.com/gh/dianper/feature-toggle)
# On/Off Feature Toggle Core
The features can be enabled by
* Cookies
* Headers
* QueryString## How to use
### Toggle Declaration
```javascript
// appsettings.json
"FeatureManagement": {
"FeatureA": false,
"FeatureB": false,
"FeatureC": {
"EnabledFor": [
{
"Name": "Cookies"
},
{
"Name": "QueryString"
}
]
},
"FeatureD": {
"EnabledFor": [
{
"Name": "Cookies"
}
]
}
}
```### Service Registration
```c#
// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddMvc();
services.AddFeatureManagement()
.AddFeatureFilter()
.AddFeatureFilter()
.AddFeatureFilter();
}
```### Dependency Injection
```c#
private readonly IFeatureManager featureManager;public DummyClass(IFeatureManager featureManager)
{
this.featureManager = featureManager;
}
```### Check
```c#
private const string FeatureName = "FeatureC";public async Task DummyMethod()
{
if(await this.featureManager.IsEnabledAsync(FeatureName))
{
// Do something
}
}
```### Build
```sh
dotnet build
```### Test
```sh
dotnet test
```### Running
Turn on by querystring
```
dotnet run --project .\src\Dianper.FeatureToggle\Dianper.FeatureToggle.Samplehttp://localhost:55715/api/values?FeatureC=true
```## Reference
[Microsoft.FeatureManagement](https://github.com/microsoft/FeatureManagement-Dotnet)