mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-09 00:34:14 +08:00
20 lines
514 B
C#
20 lines
514 B
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Net.Http;
|
|
|
|
namespace BetterGenshinImpact.Helpers.Http;
|
|
|
|
public class HttpClientFactory
|
|
{
|
|
private static readonly ConcurrentDictionary<string, HttpClient> Clients = new();
|
|
|
|
public static HttpClient GetClient(string key, Func<HttpClient> factory)
|
|
{
|
|
return Clients.GetOrAdd(key, _ => factory());
|
|
}
|
|
|
|
public static HttpClient GetCommonSendClient()
|
|
{
|
|
return Clients.GetOrAdd("common", _ => new HttpClient());
|
|
}
|
|
} |