Initialise websocket upgrade with a router. This can be the same router as the one you use for everything else or a separate router, which would be more optimal given you are testing less routes for the upgrade.
let router = Router(context: BasicWebSocketRequestContext.self)
router.ws("/ws") { request,channel in
return .upgrade([:])
} handle: { inbound, outbound, _ in
for try await packet in inbound {
if case .text("disconnect") = packet {
break
}
try await outbound.write(.custom(packet.webSocketFrame))
}
}
let app = Application(
router: router,
server: .webSocketUpgrade(webSocketRouter: router)
)
try await app.runService()
This PR also removes any NIOHTTP1 types from the public interface
Initialise websocket upgrade with a router. This can be the same router as the one you use for everything else or a separate router, which would be more optimal given you are testing less routes for the upgrade.
This PR also removes any NIOHTTP1 types from the public interface