forked from itsecd/cloud-development
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
33 lines (24 loc) · 859 Bytes
/
Program.cs
File metadata and controls
33 lines (24 loc) · 859 Bytes
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 SoftwareProjects.Api.Services;
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.AddRedisDistributedCache("cache");
builder.Services.AddScoped<ISoftwareProjectCacheService, SoftwareProjectCacheService>();
builder.Services.AddScoped<ISoftwareProjectService, SoftwareProjectService>();
var trustedOrigins = builder.Configuration
.GetSection("TrustedOrigins")
.Get<string[]>() ?? [];
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins(trustedOrigins)
.WithMethods("GET")
.AllowAnyHeader();
});
});
var app = builder.Build();
app.MapDefaultEndpoints();
app.UseCors();
app.MapGet("/api/software-projects", async (int id, ISoftwareProjectService service) =>
Results.Ok(await service.GetById(id)));
app.Run();