userver icon indicating copy to clipboard operation
userver copied to clipboard

http and websocket on a single path

Open Beshkent opened this issue 2 years ago • 2 comments

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

Beshkent avatar Sep 26 '23 13:09 Beshkent

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

apolukhin avatar Oct 26 '23 10:10 apolukhin

Is it okay to just make base virutal NonWebsocketRequest function using body like this:

{
    throw server::handlers::ClientError();
}

@segoon

RuslanGaliullin avatar May 29 '24 17:05 RuslanGaliullin

Fixed in https://github.com/userver-framework/userver/commit/e26a87671db17d781274452a72047ce4ae58ad2b

apolukhin avatar Jun 11 '24 15:06 apolukhin