fix: add routes to get routing ports & all defined routes

This commit is contained in:
Andrew Welker
2025-03-28 10:25:17 -05:00
parent 09dd8f0bcd
commit 474b2eb647
3 changed files with 126 additions and 22 deletions

View File

@@ -0,0 +1,25 @@
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web.RequestHandlers
{
public class GetRoutesHandler:WebApiBaseRequestHandler
{
private HttpCwsRouteCollection routeCollection;
public GetRoutesHandler(HttpCwsRouteCollection routeCollection) {
this.routeCollection = routeCollection;
}
protected override void HandleGet(HttpCwsContext context)
{
var response = JsonConvert.SerializeObject(routeCollection);
context.Response.StatusCode = 200;
context.Response.ContentType = "application/json";
context.Response.Headers.Add("Content-Type", "application/json");
context.Response.Write(response, false);
context.Response.End();
}
}
}