Files
LeagueARAMTracker/LeagueAPI/Utils/LcuHttpClient.cs
2026-03-13 01:22:28 +01:00

40 lines
1016 B
C#

using System.Text.Json;
namespace LeagueAPI.Utils;
public class LcuHttpClient : HttpClient
{
private LcuHttpClientHandler Handler { get; }
public ProcessInfo? ProcessInfo
{
get
{
return Handler.ProcessInfo;
}
internal set
{
Handler.ProcessInfo = value;
}
}
public RiotAuthentication? RiotAuthentication => Handler.RiotAuthentication;
public LcuHttpClient(LcuHttpClientHandler lcuHttpClientHandler)
: base(lcuHttpClientHandler)
{
Handler = lcuHttpClientHandler;
BaseAddress = new Uri("https://127.0.0.1");
}
public async Task<T?> GetContentAsync<T>(string requestUri) where T : class
{
HttpResponseMessage response = await GetAsync(requestUri);
if (!response.IsSuccessStatusCode)
{
return null;
}
string content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<T>(content);
}
}