// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include #include #include #include #include #include namespace zen { class HttpClient; class HttpProxyHandler { public: using PortValidator = std::function; HttpProxyHandler(); explicit HttpProxyHandler(PortValidator ValidatePort); ~HttpProxyHandler(); void SetPortValidator(PortValidator ValidatePort); HttpProxyHandler(const HttpProxyHandler&) = delete; HttpProxyHandler& operator=(const HttpProxyHandler&) = delete; void HandleProxyRequest(HttpServerRequest& Request, std::string_view PortStr, std::string_view PathTail); void PrunePort(uint16_t Port); void Shutdown(); void OnWebSocketOpen(Ref Connection, std::string_view RelativeUri); void OnWebSocketMessage(WebSocketConnection& Conn, const WebSocketMessage& Msg); void OnWebSocketClose(WebSocketConnection& Conn, uint16_t Code, std::string_view Reason); private: PortValidator m_ValidatePort; HttpClient& GetOrCreateProxyClient(uint16_t Port); RwLock m_ProxyClientsLock; std::unordered_map> m_ProxyClients; struct WsBridge; RwLock m_WsBridgesLock; std::unordered_map> m_WsBridges; }; } // namespace zen