userver
userver copied to clipboard
http and websocket on a single path
Add support of using the same path for both http and ws.
e.g. now WebsocketHandlerBase::HandleRequestThrow here returns server::handlers::ClientError() for non-ws connection, but could call a new pure version of Handle. Users can't override WebsocketHandlerBase::HandleRequestThrow since it is private method
Looks like WebsocketHandlerBase::HandleRequestThrow should call here a virtual function WebsocketHandlerBase::NonWebsocketRequest(const server::http::HttpRequest& request, server::request::RequestContext& context) const with default implementation of
https://github.com/userver-framework/userver/blob/develop/core/src/server/websocket/websocket_handler.cpp#L40-L43
That way, you can overload the NonWebsocketRequest and server HTTP and Websocket requests on a single path
Is it okay to just make base virutal NonWebsocketRequest function using body like this:
{
throw server::handlers::ClientError();
}
@segoon
Fixed in https://github.com/userver-framework/userver/commit/e26a87671db17d781274452a72047ce4ae58ad2b