diff --git a/src/WireMock.Net/Http/WebhookSender.cs b/src/WireMock.Net/Http/WebhookSender.cs index 95947e45..606dadd0 100644 --- a/src/WireMock.Net/Http/WebhookSender.cs +++ b/src/WireMock.Net/Http/WebhookSender.cs @@ -46,7 +46,7 @@ IResponseMessage originalResponseMessage IBodyData? bodyData; IDictionary>? headers; - string webhookRequestUrl; + string requestUrl; if (webhookRequest.UseTransformer == true) { ITransformer transformer; @@ -69,18 +69,20 @@ IResponseMessage originalResponseMessage bodyData = transformer.TransformBody(mapping, originalRequestMessage, originalResponseMessage, webhookRequest.BodyData, webhookRequest.TransformerReplaceNodeOptions); headers = transformer.TransformHeaders(mapping, originalRequestMessage, originalResponseMessage, webhookRequest.Headers); - webhookRequestUrl = transformer.TransformString(mapping, originalRequestMessage, originalResponseMessage, webhookRequest.Url); + requestUrl = transformer.TransformString(mapping, originalRequestMessage, originalResponseMessage, webhookRequest.Url); + + mapping.Settings.WebhookSettings?.PostTransform(mapping, requestUrl, bodyData, headers); } else { bodyData = webhookRequest.BodyData; headers = webhookRequest.Headers; - webhookRequestUrl = webhookRequest.Url; + requestUrl = webhookRequest.Url; } // Create RequestMessage var requestMessage = new RequestMessage( - new UrlDetails(webhookRequestUrl), + new UrlDetails(requestUrl), webhookRequest.Method, ClientIp, bodyData, @@ -91,7 +93,7 @@ IResponseMessage originalResponseMessage }; // Create HttpRequestMessage - var httpRequestMessage = HttpRequestMessageHelper.Create(requestMessage, webhookRequestUrl); + var httpRequestMessage = HttpRequestMessageHelper.Create(requestMessage, requestUrl); // Delay (if required) if (TryGetDelay(webhookRequest, out var delay)) diff --git a/src/WireMock.Net/Settings/WebhookSettings.cs b/src/WireMock.Net/Settings/WebhookSettings.cs index 79960033..3c02eda2 100644 --- a/src/WireMock.Net/Settings/WebhookSettings.cs +++ b/src/WireMock.Net/Settings/WebhookSettings.cs @@ -1,5 +1,9 @@ // Copyright © WireMock.Net +using System.Collections.Generic; +using WireMock.Types; +using WireMock.Util; + namespace WireMock.Settings; /// @@ -7,4 +11,14 @@ namespace WireMock.Settings; /// public class WebhookSettings : HttpClientSettings { + /// + /// Executes an action after the transformation of the request body. + /// + /// The mapping used for the request. + /// The request Url. + /// The body data of the request. [Optional] + /// The headers of the request. [Optional] + public virtual void PostTransform(IMapping mapping, string requestUrl, IBodyData? bodyData = null, IDictionary>? headers = null) + { + } } \ No newline at end of file