Skip to content
This repository was archived by the owner on Jun 15, 2026. It is now read-only.

Commit a3ed88e

Browse files
committed
added cloudevents v1 validation support
1 parent 141964a commit a3ed88e

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

viewer/Controllers/UpdatesController.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ public UpdatesController(IHubContext<GridEventsHub> gridEventsHubContext)
4343

4444
#region Public Methods
4545

46+
[HttpOptions]
47+
public async Task<IActionResult> Options()
48+
{
49+
using (var reader = new StreamReader(Request.Body, Encoding.UTF8))
50+
{
51+
var webhookRequestOrigin = HttpContext.Request.Headers["WebHook-Request-Origin"].FirstOrDefault();
52+
var webhookRequestCallback = HttpContext.Request.Headers["WebHook-Request-Callback"];
53+
var webhookRequestRate = HttpContext.Request.Headers["WebHook-Request-Rate"];
54+
HttpContext.Response.Headers.Add("WebHook-Allowed-Rate", "*");
55+
HttpContext.Response.Headers.Add("WebHook-Allowed-Origin", webhookRequestOrigin);
56+
}
57+
58+
return Ok();
59+
}
60+
4661
[HttpPost]
4762
public async Task<IActionResult> Post()
4863
{
@@ -122,14 +137,15 @@ await this._hubContext.Clients.All.SendAsync(
122137
private async Task<IActionResult> HandleCloudEvent(string jsonContent)
123138
{
124139
var details = JsonConvert.DeserializeObject<CloudEvent<dynamic>>(jsonContent);
140+
var eventData = JObject.Parse(jsonContent);
125141

126142
await this._hubContext.Clients.All.SendAsync(
127143
"gridupdate",
128144
details.Id,
129145
details.Type,
130-
details.Source,
146+
details.Subject,
131147
details.Time,
132-
jsonContent
148+
eventData.ToString()
133149
);
134150

135151
return Ok();

0 commit comments

Comments
 (0)