-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
33 lines (28 loc) · 1.47 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
using AhbichtClient;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpClient();
builder.Services.AddTransient<IAhbichtAuthenticator, NoAuthenticator>(); // Or you could use ClientIdClientSecretAuthenticator
builder.Services.AddHttpClient("AhbichtClient", client =>
{
client.BaseAddress = new Uri("http://localhost:7071/"); // or https://ahbicht.azurewebsites.net/
});
// you're free to use ahbicht only for _some_ of the services it provides; Just inject the ones you need
builder.Services.AddTransient<IConditionKeyToTextResolver, AhbichtClient.AhbichtRestClient>();
builder.Services.AddTransient<IPackageKeyToConditionResolver, AhbichtClient.AhbichtRestClient>();
builder.Services.AddTransient<ICategorizedKeyExtractor, AhbichtClient.AhbichtRestClient>();
builder.Services.AddTransient<IContentEvaluator, AhbichtClient.AhbichtRestClient>();
var app = builder.Build();
app.MapGet("/", () => "I ❤ AHBicht");
app.MapGet("/extractKeys", async (ICategorizedKeyExtractor ahbichtClient) =>
{
var cke = await ahbichtClient.ExtractKeys("Muss ([1] U [2] X [4])[951]");
// this is pointless, but it shows how you can use the client
return "Folgende Bedingungen müssen angegeben werden: " + string.Join(", ", cke.RequirementConstraintKeys);
});
app.Run();
namespace ExampleAspNetCoreApplication
{
public partial class Program
{
}
} // required for integration testing; If you miss this the test will complain, that it cannot find a 'testhost.deps.json'