mirror of
https://github.com/yawaflua/WebSockets.git
synced 2025-12-08 19:39:30 +02:00
25 lines
552 B
C#
25 lines
552 B
C#
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace yawaflua.WebSockets.Core.Middleware;
|
|
|
|
public class WebSocketMiddleware : IMiddleware
|
|
{
|
|
private readonly WebSocketRouter _router;
|
|
|
|
public WebSocketMiddleware(WebSocketRouter router)
|
|
{
|
|
_router = router;
|
|
}
|
|
|
|
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
|
|
{
|
|
if (context.WebSockets.IsWebSocketRequest)
|
|
{
|
|
await _router.HandleRequest(context);
|
|
}
|
|
else
|
|
{
|
|
await next(context);
|
|
}
|
|
}
|
|
} |