fix: make every Http request blocking (lol)
This commit is contained in:
parent
c1d58fbf7a
commit
864df57a5c
|
|
@ -8,10 +8,10 @@ namespace Kiseki.Launcher.Windows
|
||||||
{
|
{
|
||||||
public readonly static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
public readonly static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2];
|
||||||
|
|
||||||
public async static void Install()
|
public static void Install()
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Directories.Base);
|
Directory.CreateDirectory(Directories.Base);
|
||||||
int response = await Web.CheckHealth();
|
int response = Web.CheckHealth();
|
||||||
|
|
||||||
if (response != Web.RESPONSE_SUCCESS)
|
if (response != Web.RESPONSE_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,11 @@ namespace Kiseki.Launcher.Helpers
|
||||||
{
|
{
|
||||||
public static class Http
|
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
|
try
|
||||||
{
|
{
|
||||||
|
string json = Web.HttpClient.GetStringAsync(url).Result;
|
||||||
return JsonSerializer.Deserialize<T>(json);
|
return JsonSerializer.Deserialize<T>(json);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ namespace Kiseki.Launcher
|
||||||
public static void Initialize() => CurrentUrl = BaseUrl;
|
public static void Initialize() => CurrentUrl = BaseUrl;
|
||||||
public static string Url(string path) => $"https://{CurrentUrl}{path}";
|
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;
|
return response is null ? RESPONSE_FAILURE : response.Status;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue