-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
38 lines (27 loc) · 1.11 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using Demo.DotnetCore.FeatureManagement.Filters;
using Demo.DotnetCore.FeatureManagement.Repositories;
using Microsoft.FeatureManagement;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpContextAccessor();
builder.Services.AddSingleton<IWhitelistRepository, WhitelistRepository>();
// 環境準備:Microsoft.FeatureManagement
// 加入 Feature Flag 功能,預設會抓 appsettings.json 中的 "FeatureManagement" 節點
builder.Services
.AddFeatureManagement()
.AddFeatureFilter<RandomFilter>() // 加入自訂的 Feature Filter. see: Filters/RandomFilter.cs
.AddFeatureFilter<WhitelistFilter>();
// 如果想要自訂 Feature Flag 的設定檔位置,可以這樣寫
//builder.Services.AddFeatureManagement(builder.Configuration.GetSection("CustomFeatureManagement"));
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();