Remove sample 'weather' endpoint
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
namespace Hutopy.Application.WeatherForecasts.Queries.GetWeatherForecasts;
|
||||
|
||||
public record GetWeatherForecastsQuery : IRequest<IEnumerable<WeatherForecast>>;
|
||||
|
||||
public class GetWeatherForecastsQueryHandler : IRequestHandler<GetWeatherForecastsQuery, IEnumerable<WeatherForecast>>
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
public async Task<IEnumerable<WeatherForecast>> Handle(GetWeatherForecastsQuery request, CancellationToken cancellationToken)
|
||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
{
|
||||
var rng = new Random();
|
||||
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Hutopy.Application.WeatherForecasts.Queries.GetWeatherForecasts;
|
||||
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; init; }
|
||||
|
||||
public int TemperatureC { get; init; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; init; }
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using Hutopy.Application.WeatherForecasts.Queries.GetWeatherForecasts;
|
||||
|
||||
namespace Hutopy.Web.Endpoints;
|
||||
|
||||
public class WeatherForecasts : EndpointGroupBase
|
||||
{
|
||||
public override void Map(WebApplication app)
|
||||
{
|
||||
app.MapGroup(this)
|
||||
.RequireAuthorization()
|
||||
.MapGet(GetWeatherForecasts);
|
||||
}
|
||||
|
||||
private static async Task<IEnumerable<WeatherForecast>> GetWeatherForecasts(ISender sender)
|
||||
{
|
||||
return await sender.Send(new GetWeatherForecastsQuery());
|
||||
}
|
||||
}
|
||||
@@ -38,12 +38,6 @@ Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
# GET WeatherForecast
|
||||
GET {{base_url}}/api/WeatherForecasts
|
||||
Authorization: Bearer {{auth_token}}
|
||||
|
||||
###
|
||||
|
||||
# GET GetMyUser
|
||||
GET {{base_url}}/api/GetMyUser
|
||||
Authorization: Bearer {{auth_token}}
|
||||
|
||||
Reference in New Issue
Block a user