Mise à jour de 'src/HeartTrackAPI/Program.cs'
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
8991c502bf
commit
a7a9c57d04
@ -1,44 +1,43 @@
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
|
||||||
{
|
app.UseSwagger();
|
||||||
app.UseSwagger();
|
app.UseSwaggerUI();
|
||||||
app.UseSwaggerUI();
|
|
||||||
}
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
app.UseHttpsRedirection();
|
|
||||||
|
var summaries = new[]
|
||||||
var summaries = new[]
|
{
|
||||||
{
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
};
|
||||||
};
|
|
||||||
|
app.MapGet("/weatherforecast", () =>
|
||||||
app.MapGet("/weatherforecast", () =>
|
{
|
||||||
{
|
var forecast = Enumerable.Range(1, 5).Select(index =>
|
||||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
new WeatherForecast
|
||||||
new WeatherForecast
|
(
|
||||||
(
|
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
Random.Shared.Next(-20, 55),
|
||||||
Random.Shared.Next(-20, 55),
|
summaries[Random.Shared.Next(summaries.Length)]
|
||||||
summaries[Random.Shared.Next(summaries.Length)]
|
))
|
||||||
))
|
.ToArray();
|
||||||
.ToArray();
|
return forecast;
|
||||||
return forecast;
|
})
|
||||||
})
|
.WithName("GetWeatherForecast")
|
||||||
.WithName("GetWeatherForecast")
|
.WithOpenApi();
|
||||||
.WithOpenApi();
|
|
||||||
|
app.Run();
|
||||||
app.Run();
|
|
||||||
|
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
||||||
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
{
|
||||||
{
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in new issue