fix: make every Http request blocking (lol)

This commit is contained in:
rjindael 2023-07-31 03:55:18 -07:00
parent c1d58fbf7a
commit 864df57a5c
No known key found for this signature in database
GPG Key ID: D069369C906CCF31
3 changed files with 7 additions and 8 deletions

View File

@ -8,11 +8,11 @@ namespace Kiseki.Launcher.Windows
{
public readonly static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
public async static void Install()
public static void Install()
{
Directory.CreateDirectory(Directories.Base);
int response = await Web.CheckHealth();
int response = Web.CheckHealth();
if (response != Web.RESPONSE_SUCCESS)
{
if (response != Web.RESPONSE_MAINTENANCE)

View File

@ -4,12 +4,11 @@ namespace Kiseki.Launcher.Helpers
{
public static class Http
{
public static async Task<T?> GetJson<T>(string url)
public static T GetJson<T>(string url)
{
string json = await Web.HttpClient.GetStringAsync(url);
try
{
string json = Web.HttpClient.GetStringAsync(url).Result;
return JsonSerializer.Deserialize<T>(json);
}
catch

View File

@ -16,9 +16,9 @@ namespace Kiseki.Launcher
public static void Initialize() => CurrentUrl = BaseUrl;
public static string Url(string path) => $"https://{CurrentUrl}{path}";
public static async Task<int> CheckHealth()
public static int CheckHealth()
{
var response = await Helpers.Http.GetJson<Models.HealthCheck>(Url("/api/health"));
var response = Helpers.Http.GetJson<Models.HealthCheck>(Url("/api/health"));
return response is null ? RESPONSE_FAILURE : response.Status;
}