add list endpoint
This commit is contained in:
parent
580fe24d32
commit
e93278717f
2 changed files with 7 additions and 1 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit d677aefcff6d1c1b9e1acea5846fc666f511d64f
|
Subproject commit 0440abd027aeb35299ea05f275841a9ef012a6f4
|
|
@ -19,6 +19,7 @@ public class HTTPServer
|
||||||
#endif
|
#endif
|
||||||
builder.WebHost.UseKestrel(k => k.ListenLocalhost(Program.Config.API.HttpPort));
|
builder.WebHost.UseKestrel(k => k.ListenLocalhost(Program.Config.API.HttpPort));
|
||||||
this.app = builder.Build();
|
this.app = builder.Build();
|
||||||
|
this.app.MapGet("/api/v1/list", (Delegate) VMListHandler);
|
||||||
this.app.MapGet("/api/v1/vminfo/{vm:required}", VmInfoHandler);
|
this.app.MapGet("/api/v1/vminfo/{vm:required}", VmInfoHandler);
|
||||||
this.app.MapGet("/api/v1/screenshot/{vm:required}", VMScreenshotHandler);
|
this.app.MapGet("/api/v1/screenshot/{vm:required}", VMScreenshotHandler);
|
||||||
this.app.MapGet("/api/v1/chatlogs", (Delegate) VMChatlogHandler);
|
this.app.MapGet("/api/v1/chatlogs", (Delegate) VMChatlogHandler);
|
||||||
|
@ -27,6 +28,11 @@ public class HTTPServer
|
||||||
this.app.Lifetime.ApplicationStarted.Register(this.onServerStarted);
|
this.app.Lifetime.ApplicationStarted.Register(this.onServerStarted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<IResult> VMListHandler(HttpContext context)
|
||||||
|
{
|
||||||
|
return Results.Json(Program.VMs.Where(v => v.cvm.ConnectedToVM).Select(v => v.Config.Name).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<IResult> UsernameToIPHandler(HttpContext context, string username)
|
private async Task<IResult> UsernameToIPHandler(HttpContext context, string username)
|
||||||
{
|
{
|
||||||
if (!context.Request.Query.ContainsKey("token") ||
|
if (!context.Request.Query.ContainsKey("token") ||
|
||||||
|
|
Loading…
Reference in a new issue