Better handlers

This commit is contained in:
kssenii 2021-03-07 11:31:55 +00:00
parent 61d8e27ea7
commit 1c4d4c8e54
5 changed files with 14 additions and 13 deletions

View File

@ -15,3 +15,4 @@
#cmakedefine01 ENABLE_CLICKHOUSE_GIT_IMPORT
#cmakedefine01 ENABLE_CLICKHOUSE_INSTALL
#cmakedefine01 ENABLE_CLICKHOUSE_ODBC_BRIDGE
#cmakedefine01 ENABLE_CLICKHOUSE_LIBRARY_BRIDGE

View File

@ -17,11 +17,7 @@ namespace DB
return std::make_unique<PingHandler>(keep_alive_timeout);
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST)
{
/// Remove '/' in the beginning.
auto dictionary_id = uri.getPath().substr(1);
return std::make_unique<LibraryRequestHandler>(keep_alive_timeout, context, dictionary_id);
}
return std::make_unique<LibraryRequestHandler>(keep_alive_timeout, context);
return nullptr;
}

View File

@ -53,10 +53,18 @@ void LibraryRequestHandler::handleRequest(HTTPServerRequest & request, HTTPServe
return;
}
if (!params.has("dictionary_id"))
{
processError(response, "No 'dictionary_id in request URL");
return;
}
std::string method = params.get("method");
LOG_TRACE(log, "Library method: '{}'", method);
std::string dictionary_id = params.get("dictionary_id");
LOG_TRACE(log, "Library method: '{}', dictionary id: {}", method, dictionary_id);
WriteBufferFromHTTPServerResponse out(response, request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD, keep_alive_timeout);
try
{
if (method == "libNew")
@ -75,7 +83,6 @@ void LibraryRequestHandler::handleRequest(HTTPServerRequest & request, HTTPServe
std::string library_path = params.get("library_path");
std::string library_settings = params.get("library_settings");
LOG_TRACE(log, "Library path: '{}', library_settings: '{}'", library_path, library_settings);
bool res = SharedLibraryHandlerFactory::instance().create(dictionary_id, library_path, library_settings);

View File

@ -17,12 +17,10 @@ public:
LibraryRequestHandler(
size_t keep_alive_timeout_,
Context & context_,
const std::string & dictionary_id_)
Context & context_)
: log(&Poco::Logger::get("LibraryRequestHandler"))
, keep_alive_timeout(keep_alive_timeout_)
, context(context_)
, dictionary_id(dictionary_id_)
{
}
@ -34,7 +32,6 @@ private:
Poco::Logger * log;
size_t keep_alive_timeout;
Context & context;
const std::string dictionary_id;
};

View File

@ -32,8 +32,8 @@ LibraryBridgeHelper::LibraryBridgeHelper(
Poco::URI LibraryBridgeHelper::getDictionaryURI() const
{
auto uri = createBaseURI();
uri.setPath('/' + dictionary_id);
auto uri = getMainURI();
uri.addQueryParameter("dictionary_id", dictionary_id);
return uri;
}