cluster/WebSocket: Pass X-Application-Name to dispatcher

This is going to be used to add labels to telemetry if the
X-Application-Name header is set.
This commit is contained in:
Arne Welzel 2025-06-12 16:40:00 +02:00
parent 6a84237a95
commit 2f7d5eaf2a
2 changed files with 8 additions and 2 deletions

View file

@ -138,8 +138,13 @@ std::unique_ptr<WebSocketServer> StartServer(std::unique_ptr<WebSocketEventDispa
remoteIp = std::move(remoteIp), remoteIp = std::move(remoteIp),
ixws = std::move(ixws)](const ix::WebSocketMessagePtr& msg) mutable { ixws = std::move(ixws)](const ix::WebSocketMessagePtr& msg) mutable {
if ( msg->type == ix::WebSocketMessageType::Open ) { if ( msg->type == ix::WebSocketMessageType::Open ) {
dispatcher->QueueForProcessing( std::optional<std::string> application_name;
WebSocketOpen{id, msg->openInfo.uri, msg->openInfo.protocol, std::move(ixws)}); auto it = msg->openInfo.headers.find("X-Application-Name");
if ( it != msg->openInfo.headers.end() )
application_name = it->second;
dispatcher->QueueForProcessing(WebSocketOpen{id, msg->openInfo.uri, msg->openInfo.protocol,
std::move(application_name), std::move(ixws)});
} }
else if ( msg->type == ix::WebSocketMessageType::Message ) { else if ( msg->type == ix::WebSocketMessageType::Message ) {
dispatcher->QueueForProcessing(WebSocketMessage{id, msg->str}); dispatcher->QueueForProcessing(WebSocketMessage{id, msg->str});

View file

@ -125,6 +125,7 @@ struct WebSocketOpen {
std::string id; std::string id;
std::string uri; std::string uri;
std::string protocol; std::string protocol;
std::optional<std::string> application_name;
std::shared_ptr<WebSocketClient> wsc; std::shared_ptr<WebSocketClient> wsc;
}; };