using SentenceConverterModule.Services.Contracts;
using SentenceConverterModule.Services;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();

builder.Services.AddHttpClient();

// Converter Services
builder.Services.AddHttpClient<ITextConversionApiService, TextConversionApiService>();
builder.Services.AddScoped<ISentenceConverterService, SentenceConverterService>();

// CORS para permitir requisições do projeto principal
builder.Services.AddCors(options =>
{
    options.AddPolicy("AllowMainProject", builder =>
    {
        builder.AllowAnyOrigin()
               .AllowAnyMethod()
               .AllowAnyHeader();
    });
});

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}



app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCors("AllowMainProject");

app.UseRouting();

app.UseAuthorization();

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

app.Run();
