Aguacongas.DynamicConfiguration.WebApi
2.0.0
dotnet add package Aguacongas.DynamicConfiguration.WebApi --version 2.0.0
NuGet\Install-Package Aguacongas.DynamicConfiguration.WebApi -Version 2.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="Aguacongas.DynamicConfiguration.WebApi" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aguacongas.DynamicConfiguration.WebApi --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Aguacongas.DynamicConfiguration.WebApi, 2.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 Aguacongas.DynamicConfiguration.WebApi as a Cake Addin #addin nuget:?package=Aguacongas.DynamicConfiguration.WebApi&version=2.0.0 // Install Aguacongas.DynamicConfiguration.WebApi as a Cake Tool #tool nuget:?package=Aguacongas.DynamicConfiguration.WebApi&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Aguacongas.DynamicConfiguration.WebApi
Library to add configuration Web API to an ASP.NET 6 web site.
Setup
Program.cs
using Aguacongas.DynamicConfiguration.Redis;
using Yarp.Configuration.Model;
using Swashbuckle.AspNetCore.SwaggerUI;
using Aguacongas.DynamicConfiguration.WebApi.Controllers;
var builder = WebApplication.CreateBuilder(args);
var configuration = builder.Configuration;
// Add Redis configuration provider.
configuration.AddRedis(options => configuration.GetSection(nameof(RedisConfigurationOptions)).Bind(options));
var services = builder.Services;
// Add services to the container.
services.Configure<ReverseProxyOptions>(configuration.GetSection(nameof(ReverseProxyOptions)))
.AddAuthorization(options =>
{
// The web api requires 2 policies, DYNAMIC_CONFIGURATION_READER_POLICY and DYNAMIC_CONFIGURATION_WRITTER_POLICY
// In this sample those policies requires nothing, all users have access to the api.
// You should update this code to meet your requirement.
options.AddPolicy(ConfigurationController.DYNAMIC_CONFIGURATION_READER_POLICY,
builder => builder.RequireAssertion(context => true));
options.AddPolicy(ConfigurationController.DYNAMIC_CONFIGURATION_WRITTER_POLICY,
builder => builder.RequireAssertion(context => true));
});
services.AddAuthentication(); // this sample doesn't have authentication system but shoudl add yours.
services.AddControllersWithViews()
.AddConfigurationWebAPI(builder.Configuration, options => options.Provider = ((IConfigurationRoot)configuration).Providers.First(p => p is RedisConfigurationProvider));
services.AddRazorPages();
services.AddSwaggerGenFromConfiguration(configuration);
var app = builder.Build();
// Auto reload the configuration when changes occur.
app.SubscribeToConfigurationChanges();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseWebAssemblyDebugging();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger()
.UseSwaggerUI(c =>
{
configuration.GetSection(nameof(SwaggerUIOptions)).Bind(c);
});
}
app.UseHttpsRedirection()
.UseBlazorFrameworkFiles()
.UseStaticFiles()
.UseAuthentication()
.UseAuthorization();
app.MapRazorPages();
app.MapControllers();
app.MapFallbackToFile("index.html");
app.Run();
appsetting.json
{
"AllowedHosts": "*",
"RedisConfigurationOptions": {
"ConnectionString": "localhost",
"HashKey": "Aguacongas.DynamicConfiguration.AdminApi",
"Channel": "Aguacongas.DynamicConfiguration.AdminApi.Channel"
},
"OpenApiInfo": {
"Title": "DynamicConfiguration Admin API",
"Description": "API used to manage YARP.",
"Version": "v1",
"Contact": {
"Name": "Olivier Lefebvre",
"Email": "olivier.lefebvre@live.com",
"Url": "https://github.com/aguacongas"
}
}
}
Gets a configuration
Sets a configuration
Product | Versions 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Aguacongas.DynamicConfiguration (>= 2.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Aguacongas.DynamicConfiguration.WebApi:
Package | Downloads |
---|---|
Aguacongas.TheIdServer
OpenID/Connect , OAuth and WS-Federation server base on Duende IdentityServer. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Aguacongas.DynamicConfiguration.WebApi:
Repository | Stars |
---|---|
Aguafrommars/TheIdServer
OpenID/Connect, OAuth2, WS-Federation and SAML 2.0 server based on Duende IdentityServer and ITFoxtec Identity SAML 2.0 with its admin UI
|
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 4,477 | 11/24/2023 |
2.0.0-preview1-0080 | 807 | 10/4/2023 |
1.0.1 | 4,898 | 2/2/2023 |
1.0.1-preview1-0044 | 202 | 2/2/2023 |
1.0.0 | 8,335 | 12/25/2021 |
1.0.0-preview1-0057 | 214 | 12/23/2021 |