You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.6 KiB
56 lines
1.6 KiB
using Infrastructure;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Server.IServices;
|
|
using Asp.Versioning;
|
|
using Server.Services;
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddScoped<IAlumnisService, AlumniService>();
|
|
builder.Services.AddScoped<IExperiencesService, ExperienceServices>();
|
|
builder.Services.AddScoped<IFormationsService, FormationServices>();
|
|
builder.Services.AddScoped<IEventsService, EventServices>();
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddDbContext<AlumniDbContext>(options =>
|
|
options.UseSqlite("Data Source=FirstTest.db"));
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
//allow us to have lowercase urls (/alica instead of /Alica)
|
|
builder.Services.AddRouting(options => options.LowercaseUrls = true);
|
|
|
|
// Add API's versionning
|
|
builder.Services.AddApiVersioning(options =>
|
|
{
|
|
options.DefaultApiVersion = new ApiVersion(1, 0);
|
|
options.AssumeDefaultVersionWhenUnspecified = true;
|
|
options.ReportApiVersions = true;
|
|
})
|
|
.AddApiExplorer(options =>
|
|
{
|
|
options.GroupNameFormat = "'v'VVV";
|
|
options.SubstituteApiVersionInUrl = true;
|
|
});
|
|
|
|
builder.Services.AddSwaggerGen(c =>
|
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Alica API First Version", Version = "v1" })
|
|
);
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
// app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run(); |