fix: rename Health->HealthCheck & url format fix

This commit is contained in:
rjindael 2023-07-31 02:55:12 -07:00
parent d4c88052d9
commit c1d58fbf7a
No known key found for this signature in database
GPG Key ID: D069369C906CCF31
3 changed files with 15 additions and 12 deletions

View File

@ -1,7 +0,0 @@
namespace Kiseki.Launcher.Models
{
public class Health
{
public int Response { get; set; } = -1;
}
}

View File

@ -0,0 +1,10 @@
using System.Text.Json.Serialization;
namespace Kiseki.Launcher.Models
{
public class HealthCheck
{
[JsonPropertyName("status")]
public int Status { get; set; } = -1;
}
}

View File

@ -14,19 +14,19 @@ namespace Kiseki.Launcher
public static string CurrentUrl { get; private set; } = "";
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()
{
var response = await Helpers.Http.GetJson<Models.Health>(Url("/api/health"));
return response?.Response ?? RESPONSE_FAILURE;
var response = await Helpers.Http.GetJson<Models.HealthCheck>(Url("/api/health"));
return response is null ? RESPONSE_FAILURE : response.Status;
}
public static void LoadLicense(string license)
{
CurrentUrl = $"{MaintenanceDomain}.{CurrentUrl}";
}
}