public RedditWebAgent(IHttpClientFactory httpClientFactory, IOptions <RedditConfiguration> redditConfigurations, ILogger <RedditWebAgent> logger) { _httpClientFactory = httpClientFactory; _logger = logger; _redditConfiguration = redditConfigurations.Value; RateLimitData = new RateLimitData(); }
private void SetRateLimit(HttpResponseMessage response) { var rateLimitData = new RateLimitData { RemainingRequests = GetHeaderValue(response, "x-ratelimit-remaining"), UsedRequests = GetHeaderValue(response, "x-ratelimit-used"), TimeUntilReset = GetHeaderValue(response, "x-ratelimit-reset") }; Interlocked.Exchange(ref RateLimitData, rateLimitData); }