mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Better handlers
This commit is contained in:
parent
61d8e27ea7
commit
1c4d4c8e54
@ -15,3 +15,4 @@
|
||||
#cmakedefine01 ENABLE_CLICKHOUSE_GIT_IMPORT
|
||||
#cmakedefine01 ENABLE_CLICKHOUSE_INSTALL
|
||||
#cmakedefine01 ENABLE_CLICKHOUSE_ODBC_BRIDGE
|
||||
#cmakedefine01 ENABLE_CLICKHOUSE_LIBRARY_BRIDGE
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user