mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-20 07:21:21 +02:00
@@ -53,7 +53,7 @@ namespace WireMock.Owin.Mappers
|
||||
}
|
||||
}
|
||||
|
||||
BodyData body = null;
|
||||
IBodyData body = null;
|
||||
if (request.Body != null && BodyParser.ShouldParseBody(method, options.AllowBodyForAllHttpMethods == true))
|
||||
{
|
||||
var bodyParserSettings = new BodyParserSettings
|
||||
|
||||
@@ -9,6 +9,7 @@ using WireMock.Serialization;
|
||||
using WireMock.Types;
|
||||
using WireMock.Validation;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Settings;
|
||||
#if !USE_ASPNETCORE
|
||||
using Microsoft.Owin;
|
||||
using IContext = Microsoft.Owin.IOwinContext;
|
||||
@@ -153,6 +154,11 @@ namespace WireMock.Owin
|
||||
{
|
||||
UpdateScenarioState(targetMapping);
|
||||
}
|
||||
|
||||
if (!targetMapping.IsAdminInterface && targetMapping.Webhook != null)
|
||||
{
|
||||
await SendToWebhookAsync(targetMapping, request, response).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -184,6 +190,21 @@ namespace WireMock.Owin
|
||||
await CompletedTask;
|
||||
}
|
||||
|
||||
private async Task SendToWebhookAsync(IMapping mapping, RequestMessage request, ResponseMessage response)
|
||||
{
|
||||
var httpClientForWebhook = HttpClientBuilder.Build(mapping.Settings.WebhookSettings ?? new WebhookSettings());
|
||||
var webhookSender = new WebhookSender(mapping.Settings);
|
||||
|
||||
try
|
||||
{
|
||||
await webhookSender.SendAsync(httpClientForWebhook, mapping.Webhook.Request, request, response).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_options.Logger.Error($"Sending message to Webhook Mapping '{mapping.Guid}' failed. Exception: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScenarioState(IMapping mapping)
|
||||
{
|
||||
var scenario = _options.Scenarios[mapping.Scenario];
|
||||
|
||||
Reference in New Issue
Block a user