ClickHouse/programs/odbc-bridge/HandlerFactory.cpp

41 lines
1.2 KiB
C++
Raw Normal View History

#include "HandlerFactory.h"
#include "PingHandler.h"
#include "ColumnInfoHandler.h"
#include <Poco/URI.h>
#include <Poco/Net/HTTPServerRequest.h>
#include <common/logger_useful.h>
namespace DB
{
Poco::Net::HTTPRequestHandler * HandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & request)
{
Poco::URI uri{request.getURI()};
2020-05-23 22:24:01 +00:00
LOG_TRACE(log, "Request URI: {}", uri.toString());
if (uri.getPath() == "/ping" && request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET)
return new PingHandler(keep_alive_timeout);
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST)
{
2018-08-19 20:18:31 +00:00
if (uri.getPath() == "/columns_info")
#if USE_ODBC
return new ODBCColumnsInfoHandler(keep_alive_timeout, context);
#else
return nullptr;
2018-09-27 15:23:42 +00:00
#endif
else if (uri.getPath() == "/identifier_quote")
#if USE_ODBC
2018-09-27 15:23:42 +00:00
return new IdentifierQuoteHandler(keep_alive_timeout, context);
#else
return nullptr;
#endif
2020-04-28 00:56:44 +00:00
else if (uri.getPath() == "/write")
return new ODBCHandler(pool_map, keep_alive_timeout, context, "write");
else
2020-04-28 00:56:44 +00:00
return new ODBCHandler(pool_map, keep_alive_timeout, context, "read");
}
return nullptr;
}
}