-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
46 lines (35 loc) · 1.05 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
using CurrencyConverter.Models;
using CurrencyConverter.Services;
var builder = WebApplication.CreateBuilder(args);
var allowAll = "AllowAll";
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.Configure<List<CurrencyDetailsModel>>(builder.Configuration.GetSection("Currencies"));
builder.Services.AddSingleton<CurrencyService>();
builder.Services.AddHttpClient<CurrencyService>();
builder.Services.AddCors(options =>
{
options.AddPolicy(allowAll,
allowAll =>
{
allowAll
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
builder.Services.AddLogging(opt =>
opt.AddConfiguration(builder.Configuration.GetSection("Logging"))
.AddConsole()
.AddSentry()
);
var app = builder.Build();
// Enable public swagger because the API is also public.
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseCors(allowAll);
app.UseAuthorization();
app.MapControllers();
app.Run();