Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.0 kB · 41 lines
C#
at main
123456789101112131415161718192021222324252627282930313233343536373839404142var builder = WebApplication.CreateBuilder(args);
// Add services to the container.// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapibuilder.Services.AddOpenApi();
var app = builder.Build();
// 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.Run();
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary){ public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);}