cloudflare/ClickHouse
Publicmirrored fromhttps://github.com/cloudflare/ClickHouse
programs/odbc-bridge/HandlerFactory.cpp
46lines · modecode
Don't split dictionary source's table name into schema and table name itself if ODBC driver doesn't support schema.4733504
5 years ago
| 1 | #include "HandlerFactory.h" |
| 2 | #include "PingHandler.h" |
| 3 | #include "ColumnInfoHandler.h" |
| 4 | #include <Poco/URI.h> |
| 5 | #include <Poco/Net/HTTPServerRequest.h> |
| 6 | #include <common/logger_useful.h> |
| 7 | |
| 8 | namespace DB |
| 9 | { |
| 10 | Poco::Net::HTTPRequestHandler * HandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & request) |
| 11 | { |
| 12 | Poco::URI uri{request.getURI()}; |
| 13 | LOG_TRACE(log, "Request URI: {}", uri.toString()); |
| 14 | |
| 15 | if (uri.getPath() == "/ping" && request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET) |
| 16 | return new PingHandler(keep_alive_timeout); |
| 17 | |
| 18 | if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST) |
| 19 | { |
| 20 | |
| 21 | if (uri.getPath() == "/columns_info") |
| 22 | #if USE_ODBC |
| 23 | return new ODBCColumnsInfoHandler(keep_alive_timeout, context); |
| 24 | #else |
| 25 | return nullptr; |
| 26 | #endif |
| 27 | else if (uri.getPath() == "/identifier_quote") |
| 28 | #if USE_ODBC |
| 29 | return new IdentifierQuoteHandler(keep_alive_timeout, context); |
| 30 | #else |
| 31 | return nullptr; |
| 32 | #endif |
| 33 | else if (uri.getPath() == "/schema_allowed") |
| 34 | #if USE_ODBC |
| 35 | return new SchemaAllowedHandler(keep_alive_timeout, context); |
| 36 | #else |
| 37 | return nullptr; |
| 38 | #endif |
| 39 | else if (uri.getPath() == "/write") |
| 40 | return new ODBCHandler(pool_map, keep_alive_timeout, context, "write"); |
| 41 | else |
| 42 | return new ODBCHandler(pool_map, keep_alive_timeout, context, "read"); |
| 43 | } |
| 44 | return nullptr; |
| 45 | } |
| 46 | } |