Started adding node-daemon communication. Added status endpoint
This commit is contained in:
22
MoonlightServers.ApiServer/Extensions/NodeExtensions.cs
Normal file
22
MoonlightServers.ApiServer/Extensions/NodeExtensions.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user