From 49193ef12f950dfaa00ebd1465169d6ce000a8bc Mon Sep 17 00:00:00 2001 From: pcjones Date: Sun, 14 Apr 2024 23:22:40 +0200 Subject: [PATCH] Rename ProxyService to ProxyRequestService --- UmlautAdaptarr/Controllers/CapsController.cs | 6 +++--- UmlautAdaptarr/Controllers/SearchController.cs | 10 +++++----- UmlautAdaptarr/Program.cs | 2 +- .../{ProxyService.cs => ProxyRequestService.cs} | 8 ++++---- UmlautAdaptarr/Utilities/ServicesExtensions.cs | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) rename UmlautAdaptarr/Services/{ProxyService.cs => ProxyRequestService.cs} (91%) diff --git a/UmlautAdaptarr/Controllers/CapsController.cs b/UmlautAdaptarr/Controllers/CapsController.cs index 0d46837..9dc8fc3 100644 --- a/UmlautAdaptarr/Controllers/CapsController.cs +++ b/UmlautAdaptarr/Controllers/CapsController.cs @@ -6,9 +6,9 @@ using UmlautAdaptarr.Utilities; namespace UmlautAdaptarr.Controllers { - public class CapsController(ProxyService proxyService) : ControllerBase + public class CapsController(ProxyRequestService proxyRequestService) : ControllerBase { - private readonly ProxyService _proxyService = proxyService; + private readonly ProxyRequestService _proxyRequestService = proxyRequestService; [HttpGet] public async Task Caps([FromRoute] string options, [FromRoute] string domain, [FromQuery] string? apikey) @@ -20,7 +20,7 @@ namespace UmlautAdaptarr.Controllers var requestUrl = UrlUtilities.BuildUrl(domain, "caps", apikey); - var responseMessage = await _proxyService.ProxyRequestAsync(HttpContext, requestUrl); + var responseMessage = await _proxyRequestService.ProxyRequestAsync(HttpContext, requestUrl); var content = await responseMessage.Content.ReadAsStringAsync(); var encoding = responseMessage.Content.Headers.ContentType?.CharSet != null ? diff --git a/UmlautAdaptarr/Controllers/SearchController.cs b/UmlautAdaptarr/Controllers/SearchController.cs index 98939c3..90259d5 100644 --- a/UmlautAdaptarr/Controllers/SearchController.cs +++ b/UmlautAdaptarr/Controllers/SearchController.cs @@ -6,7 +6,7 @@ using UmlautAdaptarr.Utilities; namespace UmlautAdaptarr.Controllers { - public abstract class SearchControllerBase(ProxyService proxyService, TitleMatchingService titleMatchingService) : ControllerBase + public abstract class SearchControllerBase(ProxyRequestService proxyRequestService, TitleMatchingService titleMatchingService) : ControllerBase { // TODO evaluate if this should be set to true by default private readonly bool TODO_FORCE_TEXT_SEARCH_ORIGINAL_TITLE = true; @@ -96,7 +96,7 @@ namespace UmlautAdaptarr.Controllers private async Task PerformSingleSearchRequest(string domain, IDictionary queryParameters) { var requestUrl = UrlUtilities.BuildUrl(domain, queryParameters); - var responseMessage = await proxyService.ProxyRequestAsync(HttpContext, requestUrl); + var responseMessage = await proxyRequestService.ProxyRequestAsync(HttpContext, requestUrl); var content = await responseMessage.Content.ReadAsStringAsync(); var encoding = responseMessage.Content.Headers.ContentType?.CharSet != null ? @@ -130,7 +130,7 @@ namespace UmlautAdaptarr.Controllers { queryParameters["q"] = titleVariation; // Replace the "q" parameter for each variation var requestUrl = UrlUtilities.BuildUrl(domain, queryParameters); - var responseMessage = await proxyService.ProxyRequestAsync(HttpContext, requestUrl); + var responseMessage = await proxyRequestService.ProxyRequestAsync(HttpContext, requestUrl); var content = await responseMessage.Content.ReadAsStringAsync(); // Only update encoding from the first response @@ -152,9 +152,9 @@ namespace UmlautAdaptarr.Controllers } } - public class SearchController(ProxyService proxyService, + public class SearchController(ProxyRequestService proxyRequestService, TitleMatchingService titleMatchingService, - SearchItemLookupService searchItemLookupService) : SearchControllerBase(proxyService, titleMatchingService) + SearchItemLookupService searchItemLookupService) : SearchControllerBase(proxyRequestService, titleMatchingService) { public readonly string[] LIDARR_CATEGORY_IDS = ["3000", "3010", "3020", "3040", "3050"]; public readonly string[] READARR_CATEGORY_IDS = ["3030", "3130", "7000", "7010", "7020", "7030", "7100", "7110", "7120", "7130"]; diff --git a/UmlautAdaptarr/Program.cs b/UmlautAdaptarr/Program.cs index 622a10e..84c3a3f 100644 --- a/UmlautAdaptarr/Program.cs +++ b/UmlautAdaptarr/Program.cs @@ -56,7 +56,7 @@ internal class Program builder.AddLidarrSupport(); builder.AddReadarrSupport(); builder.Services.AddSingleton(); - builder.AddProxyService(); + builder.AddProxyRequestService(); var app = builder.Build(); diff --git a/UmlautAdaptarr/Services/ProxyService.cs b/UmlautAdaptarr/Services/ProxyRequestService.cs similarity index 91% rename from UmlautAdaptarr/Services/ProxyService.cs rename to UmlautAdaptarr/Services/ProxyRequestService.cs index 47239e6..0011244 100644 --- a/UmlautAdaptarr/Services/ProxyService.cs +++ b/UmlautAdaptarr/Services/ProxyRequestService.cs @@ -6,17 +6,17 @@ using UmlautAdaptarr.Utilities; namespace UmlautAdaptarr.Services { - public class ProxyService + public class ProxyRequestService { private readonly HttpClient _httpClient; private readonly string _userAgent; - private readonly ILogger _logger; + private readonly ILogger _logger; private readonly IMemoryCache _cache; private readonly GlobalOptions _options; private static readonly ConcurrentDictionary _lastRequestTimes = new(); private static readonly TimeSpan MINIMUM_DELAY_FOR_SAME_HOST = new(0, 0, 0, 1); - public ProxyService(IHttpClientFactory clientFactory, ILogger logger, IMemoryCache cache, IOptions options) + public ProxyRequestService(IHttpClientFactory clientFactory, ILogger logger, IMemoryCache cache, IOptions options) { _options = options.Value; _httpClient = clientFactory.CreateClient("HttpClient") ?? throw new ArgumentNullException(nameof(clientFactory)); @@ -76,7 +76,7 @@ namespace UmlautAdaptarr.Services try { - _logger.LogInformation($"ProxyService GET {UrlUtilities.RedactApiKey(targetUri)}"); + _logger.LogInformation($"ProxyRequestService GET {UrlUtilities.RedactApiKey(targetUri)}"); var responseMessage = await _httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead, context.RequestAborted); if (responseMessage.IsSuccessStatusCode) diff --git a/UmlautAdaptarr/Utilities/ServicesExtensions.cs b/UmlautAdaptarr/Utilities/ServicesExtensions.cs index 8435828..2cc188d 100644 --- a/UmlautAdaptarr/Utilities/ServicesExtensions.cs +++ b/UmlautAdaptarr/Utilities/ServicesExtensions.cs @@ -80,13 +80,13 @@ namespace UmlautAdaptarr.Utilities } /// - /// Adds a proxy service to the service collection. + /// Adds a proxy request service to the service collection. /// /// The to configure the service collection. /// The configured . - public static WebApplicationBuilder AddProxyService(this WebApplicationBuilder builder) + public static WebApplicationBuilder AddProxyRequestService(this WebApplicationBuilder builder) { - return builder.AddServiceWithOptions("Settings"); + return builder.AddServiceWithOptions("Settings"); } } }