-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
35 lines (26 loc) · 890 Bytes
/
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
// TODO: remove template comments throughout the application
using FormulaOneDemo.Middleware;
using FormulaOneDemo.Services;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
builder.Services.AddHttpClient<JolpicaApiService>(client =>
{
client.BaseAddress = new Uri("http://api.jolpi.ca/");
});
builder.Services.AddScoped<RaceMappingService>(); // TODO: should this be before HttpClient?
builder.Services.AddTransient<PrintHelloMiddleware>();
var app = builder.Build();
app.UseMiddleware<PrintHelloMiddleware>();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Races/Index");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Races}/{action=Index}/{id?}");
await app.RunAsync();