2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-05 17:39:39 -04:00
pulsar/ObservatoryCore/Utils/HttpClient.cs
2023-05-05 09:42:50 -02:30

36 lines
921 B
C#

using System;
using System.Net.Http;
namespace Observatory.Utils
{
public sealed class HttpClient
{
private HttpClient()
{ }
private static readonly Lazy<System.Net.Http.HttpClient> lazy = new Lazy<System.Net.Http.HttpClient>(() => new System.Net.Http.HttpClient());
public static System.Net.Http.HttpClient Client
{
get
{
return lazy.Value;
}
}
public static string GetString(string url)
{
return lazy.Value.GetStringAsync(url).Result;
}
public static HttpResponseMessage SendRequest(HttpRequestMessage request)
{
return lazy.Value.SendAsync(request).Result;
}
public static Task<HttpResponseMessage> SendRequestAsync(HttpRequestMessage request)
{
return lazy.Value.SendAsync(request);
}
}
}