Results and TypedResults
noun
say it: “rih-ZULTS and TYPED rih-ZULTS” /rɪˈzʌlts ænd taɪpt rɪˈzʌlts/
Minimal API helpers that build responses such as Ok(), NotFound() and Created().
What is Results and TypedResults?
Results and TypedResults create responses in minimal APIs: TypedResults.Ok(recipe), TypedResults.NotFound(). TypedResults also describes the responses in OpenAPI and is easier to test.
static async Task<Results<Ok<Recipe>, NotFound>> Get(int id, IRecipeRepository r) =>
await r.FindAsync(id) is { } recipe ? TypedResults.Ok(recipe) : TypedResults.NotFound();
In a sentence
- “The handler returns TypedResults.NotFound() when there's no such product.”
Level: Apprentice · More ASP.NET Core terms at this level
Updated