Closed
Description
When using minimal APIs, external libraries could want to expose custom results, like views. There is no way to add custom extension methods to the Results
class. However a solution could be to expose a public property e.g. Results.Custom
that could be used to expose other types of results.
Today the only solution is for each library to create their own factory class, or return an IResult
instance directly which doesn't help for discoverability, and consistency.
Example:
app.MapGet("/", () =>
{
return LiquidResults.View("index", new Todo(1, "Go back to work!", false));
});
Which could instead become:
app.MapGet("/", () =>
{
return Results.Custom.LiquidView("index", new Todo(1, "Go back to work!", false));
});