From 5172ef80a28d383e038b8bf322f8e28db2aab013 Mon Sep 17 00:00:00 2001 From: Waldek Mastykarz Date: Mon, 8 Jan 2024 16:07:46 +0100 Subject: [PATCH] Fixes warning in RateLimitingPlugin. Closes #474 (#475) --- dev-proxy-plugins/Behavior/RateLimitingPlugin.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dev-proxy-plugins/Behavior/RateLimitingPlugin.cs b/dev-proxy-plugins/Behavior/RateLimitingPlugin.cs index d958a4ac..fb637e57 100644 --- a/dev-proxy-plugins/Behavior/RateLimitingPlugin.cs +++ b/dev-proxy-plugins/Behavior/RateLimitingPlugin.cs @@ -127,10 +127,13 @@ public override void Register(IPluginEvents pluginEvents, base.Register(pluginEvents, context, urlsToWatch, configSection); configSection?.Bind(_configuration); - _configuration.CustomResponseFile = Path.GetFullPath(ProxyUtils.ReplacePathTokens(_configuration.CustomResponseFile), Path.GetDirectoryName(context.Configuration?.ConfigFile ?? string.Empty) ?? string.Empty); - _loader = new RateLimitingCustomResponseLoader(_logger!, _configuration); - // load the responses from the configured mocks file - _loader.InitResponsesWatcher(); + if (_configuration.WhenLimitExceeded == RateLimitResponseWhenLimitExceeded.Custom) + { + _configuration.CustomResponseFile = Path.GetFullPath(ProxyUtils.ReplacePathTokens(_configuration.CustomResponseFile), Path.GetDirectoryName(context.Configuration?.ConfigFile ?? string.Empty) ?? string.Empty); + _loader = new RateLimitingCustomResponseLoader(_logger!, _configuration); + // load the responses from the configured mocks file + _loader.InitResponsesWatcher(); + } pluginEvents.BeforeRequest += OnRequest; pluginEvents.BeforeResponse += OnResponse;