mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-09 21:09:51 +00:00
[feat] Add Response caching
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Caching;
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
@@ -23,7 +24,7 @@ namespace Octokit
|
||||
|
||||
readonly Authenticator _authenticator;
|
||||
readonly JsonHttpPipeline _jsonPipeline;
|
||||
readonly IHttpClient _httpClient;
|
||||
internal IHttpClient _httpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new connection instance used to make requests of the GitHub API.
|
||||
@@ -650,6 +651,21 @@ namespace Octokit
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets response cache used by the connection.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Setting this property will wrap existing <see cref="IHttpClient"/> in <see cref="CachingHttpClient"/>.
|
||||
/// </remarks>
|
||||
public IResponseCache ResponseCache
|
||||
{
|
||||
set
|
||||
{
|
||||
Ensure.ArgumentNotNull(value, nameof(value));
|
||||
_httpClient = new CachingHttpClient(_httpClient, value);
|
||||
}
|
||||
}
|
||||
|
||||
async Task<IApiResponse<string>> GetHtml(IRequest request)
|
||||
{
|
||||
request.Headers.Add("Accept", AcceptHeaders.StableVersionHtml);
|
||||
|
||||
Reference in New Issue
Block a user