mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-17 22:19:39 +02:00
Add setting to skip saving the string-response in the logging when using WithBody(Func...) (#828)
* Add extra unit-test for Response WithBody (dynamic code) * DoNotSaveDynamicResponseInLogEntry * update SettingsModel * fix * .
This commit is contained in:
@@ -69,4 +69,6 @@ internal interface IWireMockMiddlewareOptions
|
||||
bool CustomCertificateDefined { get; }
|
||||
|
||||
bool? SaveUnmatchedRequests { get; set; }
|
||||
|
||||
public bool? DoNotSaveDynamicResponseInLogEntry { get; set; }
|
||||
}
|
||||
@@ -32,22 +32,25 @@ namespace WireMock.Owin
|
||||
private readonly IOwinRequestMapper _requestMapper;
|
||||
private readonly IOwinResponseMapper _responseMapper;
|
||||
private readonly IMappingMatcher _mappingMatcher;
|
||||
private readonly LogEntryMapper _logEntryMapper;
|
||||
|
||||
#if !USE_ASPNETCORE
|
||||
public WireMockMiddleware(Next next, IWireMockMiddlewareOptions options, IOwinRequestMapper requestMapper, IOwinResponseMapper responseMapper, IMappingMatcher mappingMatcher) : base(next)
|
||||
{
|
||||
_options = Guard.NotNull(options, nameof(options));
|
||||
_requestMapper = Guard.NotNull(requestMapper, nameof(requestMapper));
|
||||
_responseMapper = Guard.NotNull(responseMapper, nameof(responseMapper));
|
||||
_mappingMatcher = Guard.NotNull(mappingMatcher, nameof(mappingMatcher));
|
||||
_options = Guard.NotNull(options);
|
||||
_requestMapper = Guard.NotNull(requestMapper);
|
||||
_responseMapper = Guard.NotNull(responseMapper);
|
||||
_mappingMatcher = Guard.NotNull(mappingMatcher);
|
||||
_logEntryMapper = new LogEntryMapper(options);
|
||||
}
|
||||
#else
|
||||
public WireMockMiddleware(Next next, IWireMockMiddlewareOptions options, IOwinRequestMapper requestMapper, IOwinResponseMapper responseMapper, IMappingMatcher mappingMatcher)
|
||||
{
|
||||
_options = Guard.NotNull(options, nameof(options));
|
||||
_requestMapper = Guard.NotNull(requestMapper, nameof(requestMapper));
|
||||
_responseMapper = Guard.NotNull(responseMapper, nameof(responseMapper));
|
||||
_mappingMatcher = Guard.NotNull(mappingMatcher, nameof(mappingMatcher));
|
||||
_options = Guard.NotNull(options);
|
||||
_requestMapper = Guard.NotNull(requestMapper);
|
||||
_responseMapper = Guard.NotNull(responseMapper);
|
||||
_mappingMatcher = Guard.NotNull(mappingMatcher);
|
||||
_logEntryMapper = new LogEntryMapper(options);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -264,7 +267,7 @@ namespace WireMock.Owin
|
||||
|
||||
private void LogRequest(LogEntry entry, bool addRequest)
|
||||
{
|
||||
_options.Logger.DebugRequestResponse(LogEntryMapper.Map(entry), entry.RequestMessage.Path.StartsWith("/__admin/"));
|
||||
_options.Logger.DebugRequestResponse(_logEntryMapper.Map(entry), entry.RequestMessage.Path.StartsWith("/__admin/"));
|
||||
|
||||
if (addRequest)
|
||||
{
|
||||
|
||||
@@ -84,4 +84,7 @@ internal class WireMockMiddlewareOptions : IWireMockMiddlewareOptions
|
||||
|
||||
/// <inheritdoc cref="IWireMockMiddlewareOptions.SaveUnmatchedRequests"/>
|
||||
public bool? SaveUnmatchedRequests { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool? DoNotSaveDynamicResponseInLogEntry { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user