add nodes to list endpoint

This commit is contained in:
Elijah R 2024-04-02 23:46:53 -04:00
parent e93278717f
commit 38fab43060

View file

@ -1,4 +1,5 @@
using System.Net; using System.Net;
using System.Text.Json.Nodes;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@ -30,7 +31,12 @@ public class HTTPServer
private async Task<IResult> VMListHandler(HttpContext context) private async Task<IResult> VMListHandler(HttpContext context)
{ {
return Results.Json(Program.VMs.Where(v => v.cvm.ConnectedToVM).Select(v => v.Config.Name).ToArray()); var j = new JsonObject();
foreach (var v in Program.VMs.Where(v => v.cvm.ConnectedToVM))
{
j[v.Config.Name] = v.Config.Node;
}
return Results.Json(j);
} }
private async Task<IResult> UsernameToIPHandler(HttpContext context, string username) private async Task<IResult> UsernameToIPHandler(HttpContext context, string username)