![]() |
VOOZH | about |
dotnet add package OpenFeature.Providers.Ofrep --version 0.1.5
NuGet\Install-Package OpenFeature.Providers.Ofrep -Version 0.1.5
<PackageReference Include="OpenFeature.Providers.Ofrep" Version="0.1.5" />
<PackageVersion Include="OpenFeature.Providers.Ofrep" Version="0.1.5" />Directory.Packages.props
<PackageReference Include="OpenFeature.Providers.Ofrep" />Project file
paket add OpenFeature.Providers.Ofrep --version 0.1.5
#r "nuget: OpenFeature.Providers.Ofrep, 0.1.5"
#:package OpenFeature.Providers.Ofrep@0.1.5
#addin nuget:?package=OpenFeature.Providers.Ofrep&version=0.1.5Install as a Cake Addin
#tool nuget:?package=OpenFeature.Providers.Ofrep&version=0.1.5Install as a Cake Tool
An OpenFeature provider implementation for the OpenFeature REST Evaluation Protocol (OFREP). This provider allows you to evaluate feature flags through a REST API that follows the OFREP specification.
Add the package to your project:
dotnet add package OpenFeature.Providers.Ofrep
using OpenFeature;
using OpenFeature.Providers.Ofrep;
using OpenFeature.Providers.Ofrep.Configuration;
// Configure the provider
var config = new OfrepOptions("https://zconfig.company.com/");
// Create and register the provider
var provider = new OfrepProvider(config);
await Api.Instance.SetProviderAsync(provider);
// Use feature flags
var client = Api.Instance.GetClient();
// Boolean flag
var boolFlag = await client.GetBooleanValueAsync("my-flag", false);
// String flag
var stringFlag = await client.GetStringValueAsync("greeting", "Hello");
// Integer flag
var intFlag = await client.GetIntegerValueAsync("max-retries", 3);
// Double flag
var doubleFlag = await client.GetDoubleValueAsync("sample-rate", 0.1);
// Advanced configuration
var config = new OfrepOptions("https://feature-flags.example.com")
{
Timeout = TimeSpan.FromSeconds(10),
Headers = new Dictionary<string, string>
{
["Custom-Header"] = "value",
["Api-Version"] = "v1"
}
};
// Create and register the provider
var provider = new OfrepProvider(config);
await Api.Instance.SetProviderAsync(provider);
For testing and scenarios where you need to control time-related behavior (such as rate limiting), you can provide a custom TimeProvider:
// Using a custom TimeProvider for testing
var customTimeProvider = new FakeTimeProvider(); // From Microsoft.Extensions.TimeProvider.Testing
var provider = new OfrepProvider(config, customTimeProvider);
When using dependency injection, the provider will automatically use any registered TimeProvider from the service container.
The OfrepOptions class supports the following options:
BaseUrl (required): The base URL for the OFREP API endpointTimeout (optional): HTTP client timeout. The default value is 10 seconds.Headers (optional): Additional HTTP headers to include in requestsThe OFREP provider supports configuration via environment variables, enabling zero-code configuration for containerized deployments and CI/CD pipelines.
| Variable | Required | Description | Example |
|---|---|---|---|
OFREP_ENDPOINT |
Yes | The OFREP server endpoint URL | http://localhost:8080 |
OFREP_HEADERS |
No | HTTP headers in Key=Value,Key2=Value2 format |
Authorization=Bearer token,X-Api-Key=abc123 |
OFREP_TIMEOUT_MS |
No | Request timeout in milliseconds (default: 10000) | 5000 |
using OpenFeature;
using OpenFeature.Providers.Ofrep;
// Create provider using environment variables (no explicit configuration needed)
var provider = new OfrepProvider();
await Api.Instance.SetProviderAsync(provider);
Or explicitly load from environment:
using OpenFeature.Providers.Ofrep.Configuration;
// Explicitly create options from environment variables
var options = OfrepOptions.FromEnvironment();
var provider = new OfrepProvider(options);
The OFREP_HEADERS environment variable uses a simple Key=Value format separated by commas.
Important parsing rules:
%2C will be decoded to , and treated as a separator).=) in the key are not supported. The first = separates the key from the value. Additional = characters in the value are allowed without encoding.%3D for =) is decoded before parsing, which is useful for systems that encode the entire value, but does not change the comma/equals parsing behavior.Examples:
# Simple headers
export OFREP_HEADERS="Authorization=Bearer token123,Content-Type=application/json"
# Header value containing equals sign (e.g., base64) - no encoding needed for additional = in value
export OFREP_HEADERS="Authorization=Bearer abc123=="
# URL-encoded equals sign in the value (decoded to =, then treated as part of the value)
export OFREP_HEADERS="X-Data=key%3Dvalue"
# Multiple headers
export OFREP_HEADERS="Authorization=Bearer token,X-Api-Key=abc123"
When using dependency injection, the provider can read configuration from IConfiguration, which supports environment variables via AddEnvironmentVariables():
// In Program.cs or Startup.cs
builder.Configuration.AddEnvironmentVariables();
builder.Services.AddOpenFeature(featureBuilder =>
{
featureBuilder.AddOfrepProvider(options =>
{
// Options will fall back to OFREP_ENDPOINT, OFREP_HEADERS, OFREP_TIMEOUT_MS
// from IConfiguration (which includes environment variables)
});
});
When multiple configuration sources are available, the following precedence order applies (highest to lowest):
OfrepOptions or OfrepProviderOptions values)Environment.GetEnvironmentVariable fallback)Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 1 NuGet packages that depend on OpenFeature.Providers.Ofrep:
| Package | Downloads |
|---|---|
|
OpenFeature.Providers.GOFeatureFlag
GO Feature Flag provider for .NET |
Showing the top 1 popular GitHub repositories that depend on OpenFeature.Providers.Ofrep:
| Repository | Stars |
|---|---|
|
CommunityToolkit/Aspire
A community project with additional components and extensions for Aspire
|