chore: unify code w/ arbiter by adding WebResponse
This commit is contained in:
parent
ed517513d6
commit
d99a44304f
|
|
@ -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; }
|
||||||
|
}
|
||||||
|
|
@ -18,10 +18,10 @@ public static class Web
|
||||||
CurrentUrl = IsInMaintenance ? $"{Constants.MAINTENANCE_DOMAIN}.{Constants.BASE_URL}" : Constants.BASE_URL;
|
CurrentUrl = IsInMaintenance ? $"{Constants.MAINTENANCE_DOMAIN}.{Constants.BASE_URL}" : Constants.BASE_URL;
|
||||||
|
|
||||||
// Synchronous block is intentional
|
// Synchronous block is intentional
|
||||||
Task<int> task = CheckHealth();
|
Task<Models.WebResponse> task = CheckHealth();
|
||||||
task.Wait();
|
task.Wait();
|
||||||
|
|
||||||
int response = task.Result;
|
int response = task.Result.Status;
|
||||||
|
|
||||||
if (response != RESPONSE_SUCCESS)
|
if (response != RESPONSE_SUCCESS)
|
||||||
{
|
{
|
||||||
|
|
@ -35,11 +35,11 @@ public static class Web
|
||||||
|
|
||||||
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 async Task<Models.WebResponse> CheckHealth()
|
||||||
{
|
{
|
||||||
var response = await Helpers.Http.GetJson<Models.HealthCheck>(Url("/api/health"));
|
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)
|
public static bool LoadLicense(string license)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue