summaryrefslogtreecommitdiffhomepage
path: root/response.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'response.cpp')
-rw-r--r--response.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/response.cpp b/response.cpp
index 29176af..eeda8d0 100644
--- a/response.cpp
+++ b/response.cpp
@@ -42,7 +42,7 @@ public:
// GetTarget() == GetPluginPath() + GetRelativePath()
- const Path& GetPath() const {return m_path;}
+ const Path& GetPath() const {return m_path;} // GetPluginPath w/ configured params as struct
std::string GetPluginName() const {return m_path.params.at("plugin");} // can throw std::out_of_range
@@ -297,7 +297,7 @@ response_type handleAuth(RequestContext& req_ctx, response_type& res)
} // anonymous namespace
-response_type generate_response(request_type& req, Server& server)
+response_type response::generate_response(request_type& req, Server& server)
{
response_type res{http::status::ok, req.version()};
res.set(http::field::server, Server::VersionString);
@@ -334,3 +334,26 @@ response_type generate_response(request_type& req, Server& server)
}
+std::string response::get_websocket_address(request_type& req, Server& server)
+{
+ try {
+ std::cout << "DEBUG0" << std::endl;
+ std::cout << "DEBUG0: " << req.target() << std::endl;
+ RequestContext req_ctx{req, server}; // can throw std::out_of_range
+
+ std::cout << "DEBUG1" << std::endl;
+ if (req_ctx.GetPluginName() != "websocket") {
+ std::cout << "Bad plugin configured for websocket request: " << req_ctx.GetPluginName() << std::endl;
+ return {};
+ }
+
+ std::cout << "DEBUG2" << std::endl;
+ return req_ctx.GetDocRoot(); // Configured "path" in config: host:port for websocket
+ std::cout << "DEBUG3" << std::endl;
+
+ } catch (const std::exception& ex) {
+ std::cout << "No matching configured target websocket found: " << ex.what() << std::endl;
+ return {};
+ }
+}
+