Browse Source

added a HttpClientFactoryRestClientProvider to avoid having to expose a HttpClientFactoryRestClient.

pull/1806/head
emorell96 4 years ago
parent
commit
35e0d1068e
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      src/Discord.Net.Rest/Net/HttpClientFactoryRestClientProvider.cs

+ 25
- 0
src/Discord.Net.Rest/Net/HttpClientFactoryRestClientProvider.cs View File

@@ -0,0 +1,25 @@
using System;
using System.Net.Http;

namespace Discord.Net.Rest
{
public static class HttpClientFactoryRestClientProvider
{

/// <exception cref="PlatformNotSupportedException">The default RestClientProvider is not supported on this platform.</exception>
public static RestClientProvider Create(HttpClient httpClient, bool useProxy = false)
{
return url =>
{
try
{
return new HttpClientFactoryRestClient(url, httpClient, useProxy);
}
catch (PlatformNotSupportedException ex)
{
throw new PlatformNotSupportedException("The default RestClientProvider is not supported on this platform.", ex);
}
};
}
}
}

Loading…
Cancel
Save