2022-08-03 11:19:13 +00:00
|
|
|
#include "ODBCHandlerFactory.h"
|
2018-08-19 17:09:54 +00:00
|
|
|
#include "PingHandler.h"
|
|
|
|
#include "ColumnInfoHandler.h"
|
2022-09-28 08:45:15 +00:00
|
|
|
#include "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>
|
2022-04-27 15:05:45 +00:00
|
|
|
#include <Common/logger_useful.h>
|
2018-08-08 16:15:29 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-02-19 12:51:26 +00:00
|
|
|
|
2024-03-22 20:24:53 +00:00
|
|
|
ODBCBridgeHandlerFactory::ODBCBridgeHandlerFactory(const std::string & name_, ContextPtr context_)
|
|
|
|
: WithContext(context_), log(getLogger(name_)), name(name_)
|
2022-08-03 11:19:13 +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)
|
2024-03-22 20:24:53 +00:00
|
|
|
return std::make_unique<PingHandler>();
|
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
|
2024-03-22 20:07:12 +00:00
|
|
|
return std::make_unique<ODBCColumnsInfoHandler>(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
|
2024-03-22 20:07:12 +00:00
|
|
|
return std::make_unique<IdentifierQuoteHandler>(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
|
2024-03-22 20:07:12 +00:00
|
|
|
return std::make_unique<SchemaAllowedHandler>(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")
|
2024-03-22 20:07:12 +00:00
|
|
|
return std::make_unique<ODBCHandler>(getContext(), "write");
|
2018-08-19 17:09:54 +00:00
|
|
|
else
|
2024-03-22 20:07:12 +00:00
|
|
|
return std::make_unique<ODBCHandler>(getContext(), "read");
|
2018-08-19 17:09:54 +00:00
|
|
|
}
|
2018-08-08 16:15:29 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|