33 lines
853 B
C#
33 lines
853 B
C#
using System.Reflection;
|
|
using EndavaTask.Data;
|
|
using EndavaTask.Middleware;
|
|
using EndavaTask.Services;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen(options =>
|
|
{
|
|
var xmlFileName = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
|
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFileName);
|
|
options.IncludeXmlComments(xmlPath);
|
|
});
|
|
builder.Services.AddSingleton<IProductRepository, InMemoryProductRepository>();
|
|
builder.Services.AddScoped<IProductService, ProductService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseGlobalExceptionHandling();
|
|
app.UseHttpsRedirection();
|
|
app.UseAuthorization();
|
|
app.MapControllers();
|
|
|
|
app.Run();
|