app.MapGet("/products", (context) => { IEnumerable<Product> products = app.Services.GetService<JsonFileProductService>().GetProducts(); var json = JsonSerializer.Serialize<IEnumerable<Product>>(products); return context.Response.WriteAsync(json); });
app.MapGet("/products", (context) =>
{
IEnumerable products = app.Services.GetService().GetProducts();
var json = JsonSerializer.Serialize<IEnumerable>(products);
return context.Response.WriteAsync(json);
});