You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Common/Extensions/HttpClientFactoryExtensions.cs

23 lines
774 B

using System;
using System.Net.Http;
using MediaBrowser.Common.Plugins;
namespace MediaBrowser.Common.Extensions;
/// <summary>
/// Extensions for <see cref="IServiceProvider"/>.
/// </summary>
public static class HttpClientFactoryExtensions
{
/// <summary>
/// Get a plugin-configured HttpClient.
/// This requires calling <c>AddHttpClient{T}</c> during <c>RegisterServices</c>.
/// </summary>
/// <param name="httpClientFactory">The http client factory.</param>
/// <typeparam name="T">The type of plugin.</typeparam>
/// <returns>The HttpClient.</returns>
public static HttpClient GetPluginHttpClient<T>(this IHttpClientFactory httpClientFactory)
where T : BasePlugin
=> httpClientFactory.CreateClient(typeof(T).Name);
}