Skip to content

Instantly share code, notes, and snippets.

@shawnwildermuth
Created July 27, 2021 05:42
Show Gist options
  • Save shawnwildermuth/9d42b12d55a25ff2ac617eec2b21104b to your computer and use it in GitHub Desktop.
Save shawnwildermuth/9d42b12d55a25ff2ac617eec2b21104b to your computer and use it in GitHub Desktop.
Using IActionResult in Minimal API
app.MapPost("/api/messenger", (Func<ContactModel, IMailService, IGoogleCaptchaService, string, Task<IActionResult>>)
(async ([FromBody] model, svc, captcha, template) =>
{
if (await captcha.Verify(model.Recaptcha))
{
if (await svc.SendMailAsync(template, model))
{
return new OkResult();
}
}
return new BadRequestResult();
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment