Started adding node-daemon communication. Added status endpoint

This commit is contained in:
=
2024-09-06 13:53:41 +00:00
parent 66e0fa2283
commit 6d4e1cdaaf
11 changed files with 144 additions and 24 deletions

View File

@@ -0,0 +1,22 @@
using MoonCore.Helpers;
using MoonlightServers.ApiServer.Database.Entities;
namespace MoonlightServers.ApiServer.Extensions;
public static class NodeExtensions
{
public static HttpApiClient CreateClient(this Node node)
{
var httpClient = new HttpClient(new HttpClientHandler() // TODO: Make global http config for proxy etc
{
UseProxy = false
});
var url = $"{(node.SslEnabled ? "https" : "http")}://{node.Fqdn}:{node.ApiPort}/";
httpClient.BaseAddress = new Uri(url);
httpClient.DefaultRequestHeaders.Add("Authorization", node.Token);
return new HttpApiClient(httpClient);
}
}