2025-03-10 21:44:51 -05:00
|
|
|
|
using LANCommander.SDK.Extensions;
|
|
|
|
|
|
using LANCommander.Server.Services;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.Server
|
|
|
|
|
|
{
|
|
|
|
|
|
public class PingMiddleware(RequestDelegate next)
|
|
|
|
|
|
{
|
|
|
|
|
|
public async Task InvokeAsync(HttpContext context)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (context.Request.Method == "HEAD" && context.Request.Headers.ContainsKey("X-Ping"))
|
2025-03-11 02:05:31 -05:00
|
|
|
|
{
|
2025-03-10 21:44:51 -05:00
|
|
|
|
context.Response.Headers["X-Pong"] = context.Request.Headers["X-Ping"].First().FastReverse();
|
2025-03-11 02:05:31 -05:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-03-10 21:44:51 -05:00
|
|
|
|
}
|
2025-03-11 01:34:11 -05:00
|
|
|
|
catch { }
|
|
|
|
|
|
|
|
|
|
|
|
await next(context);
|
2025-03-10 21:44:51 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|