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"
|
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>
|
|
|
|
#include <common/logger_useful.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
Poco::Net::HTTPRequestHandler * HandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & request)
|
|
|
|
{
|
2018-08-19 17:09:54 +00:00
|
|
|
Poco::URI uri{request.getURI()};
|
|
|
|
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)
|
2018-08-08 16:15:29 +00:00
|
|
|
return new PingHandler(keep_alive_timeout);
|
|
|
|
|
|
|
|
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
|
2018-08-19 17:09:54 +00:00
|
|
|
return new ODBCColumnsInfoHandler(keep_alive_timeout, context);
|
|
|
|
#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
|
2018-09-27 15:23:42 +00:00
|
|
|
return new IdentifierQuoteHandler(keep_alive_timeout, context);
|
|
|
|
#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")
|
|
|
|
return new ODBCHandler(pool_map, keep_alive_timeout, context, "write");
|
2018-08-19 17:09:54 +00:00
|
|
|
else
|
2020-04-28 00:56:44 +00:00
|
|
|
return new ODBCHandler(pool_map, keep_alive_timeout, context, "read");
|
2018-08-19 17:09:54 +00:00
|
|
|
}
|
2018-08-08 16:15:29 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|