chore: unify code w/ arbiter by adding WebResponse

This commit is contained in:
rjindael 2023-08-02 23:06:41 -07:00
parent ed517513d6
commit d99a44304f
No known key found for this signature in database
GPG Key ID: D069369C906CCF31
2 changed files with 17 additions and 4 deletions

View File

@ -0,0 +1,13 @@
namespace Kiseki.Launcher.Models;
public readonly struct WebResponse
{
public WebResponse(int status, object? data)
{
Status = status;
Data = data;
}
public int Status { get; }
public object? Data { get; }
}

View File

@ -18,10 +18,10 @@ public static class Web
CurrentUrl = IsInMaintenance ? $"{Constants.MAINTENANCE_DOMAIN}.{Constants.BASE_URL}" : Constants.BASE_URL;
// Synchronous block is intentional
Task<int> task = CheckHealth();
Task<Models.WebResponse> task = CheckHealth();
task.Wait();
int response = task.Result;
int response = task.Result.Status;
if (response != RESPONSE_SUCCESS)
{
@ -35,11 +35,11 @@ public static class Web
public static string Url(string path) => $"https://{CurrentUrl}{path}";
public static async Task<int> CheckHealth()
public static async Task<Models.WebResponse> CheckHealth()
{
var response = await Helpers.Http.GetJson<Models.HealthCheck>(Url("/api/health"));
return response?.Status ?? RESPONSE_FAILURE;
return new Models.WebResponse(response?.Status ?? RESPONSE_FAILURE, response);
}
public static bool LoadLicense(string license)