-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
50 lines (38 loc) · 1.46 KB
/
Program.cs
File metadata and controls
50 lines (38 loc) · 1.46 KB
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
using DsaApi.Application.Interfaces;
using DsaApi.Application.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen((c =>
{
c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "DSA API", Version = "v1" });
}));
// Add Logging
builder.Services.AddLogging(loggingBuilder =>
{
loggingBuilder.AddConsole();
loggingBuilder.AddDebug();
// Add other providers like Seq, Application Insights, etc. here if needed
});
// *** Register Application Layer Services ***
// Use AddSingleton for this demo service because it holds state in memory.
// WARNING: This means ONE stack shared by ALL requests. Not suitable for production multi-user scenarios.
// For production, state would likely be external (DB, Cache) and services might be Scoped or Transient.
builder.Services.AddSingleton<IStackService, InMemoryStackService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI((c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "DSA API V1");
c.RoutePrefix = string.Empty; // Serve Swagger UI at the app's root
}));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();