-
Notifications
You must be signed in to change notification settings - Fork 114
/
Program.cs
61 lines (44 loc) · 1.4 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
using Microsoft.FeatureManagement;
using VariantServiceDemo;
var builder = WebApplication.CreateBuilder(args);
//
// What a web app using app insights looks like
//
// Add services to the container.
builder.Services.AddRazorPages();
//
// Use cookie auth for simplicity and randomizing user
builder.Services.AddAuthentication("CookieAuth");
builder.Services.AddApplicationInsightsTelemetry();
//
// Add variant implementations of ICalculator
builder.Services.AddSingleton<ICalculator, DefaultCalculator>();
builder.Services.AddSingleton<ICalculator, RemoteCalculator>();
//
// Enter feature management
//
// Enhance a web application with feature management
// Including user targeting capability and the variant service provider of ICalculator which is bounded with the variant feature flag "Calculator"
// Wire up evaluation event emission
builder.Services.AddFeatureManagement()
.WithTargeting()
.WithVariantService<ICalculator>("Calculator")
.AddApplicationInsightsTelemetry();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
//
// Add Targeting Id to HttpContext
app.UseMiddleware<TargetingHttpContextMiddleware>();
app.Run();