This commit is contained in:
prixod
2025-10-24 23:29:56 +04:00
parent 8af94da831
commit 3d854c3470
18 changed files with 330 additions and 45 deletions

View File

@@ -1,41 +1,26 @@
using LiquidCode.Tester.Gateway.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
// Add services to the container
builder.Services.AddControllers();
builder.Services.AddOpenApi();
// Add HttpClient
builder.Services.AddHttpClient();
// Register application services
builder.Services.AddSingleton<IPackageDownloadService, PackageDownloadService>();
builder.Services.AddSingleton<IWorkerClientService, WorkerClientService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
// Configure the HTTP request pipeline
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseHttpsRedirection();
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast");
app.MapControllers();
app.Run();
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}