using WebApplication1;

var builder = WebApplication.CreateBuilder(args);

// Agrega MVC
//builder.Services.AddControllersWithViews();
builder.Services.AddControllersWithViews(); // Soporte para vistas (como Index)
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddTransient<RecetaRecetum>();

// Agrega Swagger
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configura pipeline
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

// Swagger (normalmente sólo en desarrollo, pero lo puedes dejar siempre si gustas)
app.UseSwagger();
app.UseSwaggerUI();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();