PIAPS_CW/RestAPI/Program.cs

49 lines
1.2 KiB
C#
Raw Normal View History

2024-06-05 01:25:18 +04:00
using BusinessLogic.BusinessLogic;
using Contracts.BusinessLogicContracts;
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Microsoft.OpenApi.Models;
using System;
const string VERSION = "v1";
const string TITLE = "21GunsRestAPI";
2024-05-09 17:45:03 +04:00
var builder = WebApplication.CreateBuilder(args);
2024-06-05 01:25:18 +04:00
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddLog4Net("log4net.config");
#region DI
builder.Services.AddTransient<IRoleLogic, RoleLogic>();
builder.Services.AddTransient<IUserLogic, UserLogic>();
builder.Services.AddTransient<IRoleStorage, RoleStorage>();
builder.Services.AddTransient<IUserStorage, UserStorage>();
#endregion DI
2024-05-09 17:45:03 +04:00
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
2024-06-05 01:25:18 +04:00
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc(VERSION, new OpenApiInfo { Title = TITLE, Version = VERSION });
});
2024-05-09 17:45:03 +04:00
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
2024-06-05 01:25:18 +04:00
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint($"/swagger/{VERSION}/swagger.json", $"{TITLE} {VERSION}"));
2024-05-09 17:45:03 +04:00
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
2024-06-05 01:25:18 +04:00
app.Run();