public async Task <IActionResult> RunAsync( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "publish/{source}/{eventType}")] HttpRequest req, string source, string eventType, CancellationToken cancellationToken) { _logger.SetContext(req.Headers); _logger.Info($"Received event publication for {source}.{eventType}"); string payload; using (var reader = new StreamReader(req.Body)) { payload = await reader.ReadToEndAsync(); } _logger.Info($"Read payload {payload}"); try { await _receiveManager.ReceiveAsync(source, eventType, payload, cancellationToken); return(new AcceptedResult()); } catch (InvalidRequestException ex) { _logger.Info($"Returning bad request ({ex.Code}) - {ex.Message}"); return(new HttpErrorBodyResult(HttpStatusCode.BadRequest, $"SPI-EVBK-{ex.Code}", ex.Message)); } }
public async Task <IActionResult> RunAsync( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "events")] HttpRequest req, CancellationToken cancellationToken) { _logger.SetContext(req.Headers); var rootObject = await ReadAndValidateRequestAsync(req); var publisher = ConvertJsonToPublisher(rootObject); await _publisherManager.UpdatePublishedEventsAsync(publisher, cancellationToken); return(new AcceptedResult()); }