Created
July 27, 2021 05:42
-
-
Save shawnwildermuth/9d42b12d55a25ff2ac617eec2b21104b to your computer and use it in GitHub Desktop.
Using IActionResult in Minimal API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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