Created
January 20, 2020 19:25
-
-
Save dbarkol/78ab19872e272988465c5209cd294226 to your computer and use it in GitHub Desktop.
Validation response for CloudEvents in ASP.NET Core Web 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
[HttpOptions] | |
public async Task<IActionResult> Options() | |
{ | |
using (var reader = new StreamReader(Request.Body, Encoding.UTF8)) | |
{ | |
// Retrieve the validation header fields | |
var webhookRequestOrigin = HttpContext.Request.Headers["WebHook-Request-Origin"].FirstOrDefault(); | |
var webhookRequestCallback = HttpContext.Request.Headers["WebHook-Request-Callback"]; | |
var webhookRequestRate = HttpContext.Request.Headers["WebHook-Request-Rate"]; | |
// Respond with the appropriate origin and allowed rate to | |
// confirm acceptance of incoming notications | |
HttpContext.Response.Headers.Add("WebHook-Allowed-Rate", "*"); | |
HttpContext.Response.Headers.Add("WebHook-Allowed-Origin", webhookRequestOrigin); | |
} | |
return Ok(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment