2018-08-08 16:15:29 +00:00
|
|
|
#include "HandlerFactory.h"
|
2018-08-19 17:09:54 +00:00
|
|
|
#include "PingHandler.h"
|
|
|
|
#include "ColumnInfoHandler.h"
|
2022-01-18 06:49:10 +00:00
|
|
|
#include <Common/config.h>
|
2018-09-14 19:48:51 +00:00
|
|
|
#include <Poco/URI.h>
|
2018-08-08 16:15:29 +00:00
|
|
|
#include <Poco/Net/HTTPServerRequest.h>
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/logger_useful.h>
|
2018-08-08 16:15:29 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-02-19 12:51:26 +00:00
|
|
|
|
2021-03-07 13:55:40 +00:00
|
|
|
std::unique_ptr<HTTPRequestHandler> ODBCBridgeHandlerFactory::createRequestHandler(const HTTPServerRequest & request)
|
2018-08-08 16:15:29 +00:00
|
|
|
{
|
2018-08-19 17:09:54 +00:00
|
|
|
Poco::URI uri{request.getURI()};
|
2020-05-23 22:24:01 +00:00
|
|
|
LOG_TRACE(log, "Request URI: {}", uri.toString());
|
2018-08-08 16:15:29 +00:00
|
|
|
|
2018-08-19 17:09:54 +00:00
|
|
|
if (uri.getPath() == "/ping" && request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET)
|
2021-02-19 12:51:26 +00:00
|
|
|
return std::make_unique<PingHandler>(keep_alive_timeout);
|
2018-08-08 16:15:29 +00:00
|
|
|
|
|
|
|
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST)
|
2018-08-19 17:09:54 +00:00
|
|
|
{
|
2018-08-08 16:15:29 +00:00
|
|
|
|
2018-08-19 20:18:31 +00:00
|
|
|
if (uri.getPath() == "/columns_info")
|
2020-05-08 14:11:19 +00:00
|
|
|
#if USE_ODBC
|
2021-04-10 23:33:54 +00:00
|
|
|
return std::make_unique<ODBCColumnsInfoHandler>(keep_alive_timeout, getContext());
|
2018-08-19 17:09:54 +00:00
|
|
|
#else
|
|
|
|
return nullptr;
|
2018-09-27 15:23:42 +00:00
|
|
|
#endif
|
2018-11-23 18:52:00 +00:00
|
|
|
else if (uri.getPath() == "/identifier_quote")
|
2020-05-08 14:11:19 +00:00
|
|
|
#if USE_ODBC
|
2021-04-10 23:33:54 +00:00
|
|
|
return std::make_unique<IdentifierQuoteHandler>(keep_alive_timeout, getContext());
|
2018-09-27 15:23:42 +00:00
|
|
|
#else
|
|
|
|
return nullptr;
|
2020-07-06 12:23:36 +00:00
|
|
|
#endif
|
|
|
|
else if (uri.getPath() == "/schema_allowed")
|
|
|
|
#if USE_ODBC
|
2021-04-10 23:33:54 +00:00
|
|
|
return std::make_unique<SchemaAllowedHandler>(keep_alive_timeout, getContext());
|
2020-07-06 12:23:36 +00:00
|
|
|
#else
|
|
|
|
return nullptr;
|
2018-08-19 17:09:54 +00:00
|
|
|
#endif
|
2020-04-28 00:56:44 +00:00
|
|
|
else if (uri.getPath() == "/write")
|
2021-04-11 06:13:11 +00:00
|
|
|
return std::make_unique<ODBCHandler>(keep_alive_timeout, getContext(), "write");
|
2018-08-19 17:09:54 +00:00
|
|
|
else
|
2021-04-11 06:13:11 +00:00
|
|
|
return std::make_unique<ODBCHandler>(keep_alive_timeout, getContext(), "read");
|
2018-08-19 17:09:54 +00:00
|
|
|
}
|
2018-08-08 16:15:29 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|