Cristo bastardo
This commit is contained in:
62
PizzaExpress/Program.cs
Normal file
62
PizzaExpress/Program.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PizzaExpress.Data;
|
||||
|
||||
namespace PizzaExpress
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy(name: MyAllowSpecificOrigins,
|
||||
policy =>
|
||||
{
|
||||
policy.WithOrigins("http://127.0.0.1:5500",
|
||||
"http://localhost:5500")
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers()
|
||||
.AddXmlSerializerFormatters();
|
||||
|
||||
// DB in memory perch<63> siamo froci
|
||||
builder.Services.AddDbContext<PizzaContext>(opt =>
|
||||
opt.UseInMemoryDatabase("dbpizze"));
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
using (var porcoidddioooo = app.Services.CreateScope())
|
||||
{
|
||||
var ctx = porcoidddioooo.ServiceProvider.GetRequiredService<PizzaContext>();
|
||||
SeedData.Initialize(ctx);
|
||||
}
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseCors(MyAllowSpecificOrigins);
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user