ClickHouse/programs/odbc-bridge/ODBCHandlerFactory.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.6 KiB
C++
Raw Normal View History

#include "ODBCHandlerFactory.h"
#include "PingHandler.h"
#include "ColumnInfoHandler.h"
#include "config.h"
#include <Poco/URI.h>
#include <Poco/Net/HTTPServerRequest.h>
2022-04-27 15:05:45 +00:00
#include <Common/logger_useful.h>
namespace DB
{
2024-03-22 20:24:53 +00:00
ODBCBridgeHandlerFactory::ODBCBridgeHandlerFactory(const std::string & name_, ContextPtr context_)
: WithContext(context_), log(getLogger(name_)), name(name_)
{
}
2021-03-07 13:55:40 +00:00
std::unique_ptr<HTTPRequestHandler> ODBCBridgeHandlerFactory::createRequestHandler(const 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)
2024-03-22 20:24:53 +00:00
return std::make_unique<PingHandler>();
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST)
{
2018-08-19 20:18:31 +00:00
if (uri.getPath() == "/columns_info")
#if USE_ODBC
2024-03-22 20:07:12 +00:00
return std::make_unique<ODBCColumnsInfoHandler>(getContext());
#else
return nullptr;
2018-09-27 15:23:42 +00:00
#endif
else if (uri.getPath() == "/identifier_quote")
#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;
#endif
else if (uri.getPath() == "/schema_allowed")
#if USE_ODBC
2024-03-22 20:07:12 +00:00
return std::make_unique<SchemaAllowedHandler>(getContext());
#else
return nullptr;
#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");
else
2024-03-22 20:07:12 +00:00
return std::make_unique<ODBCHandler>(getContext(), "read");
}
return nullptr;
}
}