feat: 增加健康检查页面

This commit is contained in:
Argo-Tianyi 2022-01-03 00:15:56 +08:00
parent 490c8f87eb
commit c633dd4a81
1 changed files with 43 additions and 1 deletions

View File

@ -1,5 +1,47 @@
namespace BootstrapAdmin.Web.Pages.Admin;
using BootstrapAdmin.Web.Services;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace BootstrapAdmin.Web.Pages.Admin;
public partial class Healths
{
[Inject]
[NotNull]
private IHttpClientFactory? HttpClientFactory { get; set; }
[Inject]
[NotNull]
private NavigationManager? NavigationManager { get; set; }
/// <summary>
/// OnInitializedAsync
/// </summary>
/// <returns></returns>
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
var client = HttpClientFactory.CreateClient();
client.BaseAddress = new Uri(NavigationManager.BaseUri);
var payload = await client.GetStringAsync("/Healths");
var serializeOption = new JsonSerializerOptions
{
PropertyNamingPolicy = null,
PropertyNameCaseInsensitive = true
};
serializeOption.Converters.Add(new StringToTimeSpanConverter());
var report = JsonSerializer.Deserialize<dynamic>(payload, serializeOption);
if (report != null)
{
foreach (var entry in report.Keys)
{
var item = report.Entries[entry];
}
}
}
}