change route
This commit is contained in:
@@ -1,19 +1,43 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
using PyroFetes;
|
||||
using FastEndpoints;
|
||||
using FastEndpoints.Swagger;
|
||||
using FastEndpoints.Security;
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var app = builder.Build();
|
||||
// On ajoute ici FastEndpoints, un framework REPR et Swagger aux services disponibles dans le projet
|
||||
builder.Services
|
||||
.AddAuthenticationJwtBearer(s => s.SigningKey = "zewsxrdctfvgybuhbgyvftrcdtfvgbyuhn")
|
||||
.AddAuthorization()
|
||||
.AddFastEndpoints().SwaggerDocument(options => { options.ShortSchemaNames = true;});
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
// On ajoute ici la configuration de la base de données
|
||||
builder.Services.AddDbContext<PyroFetesDbContext>();
|
||||
|
||||
//On ajoute le CORS au code
|
||||
builder.Services.AddCors(options =>
|
||||
{ options.AddDefaultPolicy(policyBuilder =>
|
||||
{
|
||||
policyBuilder
|
||||
.WithOrigins("http://localhost:4200")
|
||||
.WithMethods("GET", "POST", "PUT", "PATCH", "DELETE")
|
||||
.AllowAnyHeader();
|
||||
});
|
||||
});
|
||||
|
||||
// On construit l'application en lui donnant vie
|
||||
WebApplication app = builder.Build();
|
||||
app.UseAuthentication()
|
||||
.UseAuthorization()
|
||||
.UseFastEndpoints(options =>
|
||||
{
|
||||
options.Endpoints.RoutePrefix = "API";
|
||||
options.Endpoints.ShortNames = true;
|
||||
}
|
||||
).UseSwaggerGen();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseCors();
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user