Skip to content

Commit 5172ef8

Browse files
Fixes warning in RateLimitingPlugin. Closes #474 (#475)
1 parent 0f79be1 commit 5172ef8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

dev-proxy-plugins/Behavior/RateLimitingPlugin.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,13 @@ public override void Register(IPluginEvents pluginEvents,
127127
base.Register(pluginEvents, context, urlsToWatch, configSection);
128128

129129
configSection?.Bind(_configuration);
130-
_configuration.CustomResponseFile = Path.GetFullPath(ProxyUtils.ReplacePathTokens(_configuration.CustomResponseFile), Path.GetDirectoryName(context.Configuration?.ConfigFile ?? string.Empty) ?? string.Empty);
131-
_loader = new RateLimitingCustomResponseLoader(_logger!, _configuration);
132-
// load the responses from the configured mocks file
133-
_loader.InitResponsesWatcher();
130+
if (_configuration.WhenLimitExceeded == RateLimitResponseWhenLimitExceeded.Custom)
131+
{
132+
_configuration.CustomResponseFile = Path.GetFullPath(ProxyUtils.ReplacePathTokens(_configuration.CustomResponseFile), Path.GetDirectoryName(context.Configuration?.ConfigFile ?? string.Empty) ?? string.Empty);
133+
_loader = new RateLimitingCustomResponseLoader(_logger!, _configuration);
134+
// load the responses from the configured mocks file
135+
_loader.InitResponsesWatcher();
136+
}
134137

135138
pluginEvents.BeforeRequest += OnRequest;
136139
pluginEvents.BeforeResponse += OnResponse;

0 commit comments

Comments
 (0)