mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-08 08:35:20 +00:00
414f470c79
* Refactoring: part 1 * Refactoring: part 2 * Handle request using ReadBuffer interface * Struggles with ReadBuffer's * Fix URI parsing * Implement parsing of multipart/form-data * Check HTTP_LENGTH_REQUIRED before eof() or will hang * Fix HTTPChunkedReadBuffer * Fix build and style * Fix test * Resist double-eof * Fix arcadian build
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#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
|
|
{
|
|
|
|
std::unique_ptr<HTTPRequestHandler> HandlerFactory::createRequestHandler(const HTTPServerRequest & request)
|
|
{
|
|
Poco::URI uri{request.getURI()};
|
|
LOG_TRACE(log, "Request URI: {}", uri.toString());
|
|
|
|
if (uri.getPath() == "/ping" && request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET)
|
|
return std::make_unique<PingHandler>(keep_alive_timeout);
|
|
|
|
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST)
|
|
{
|
|
|
|
if (uri.getPath() == "/columns_info")
|
|
#if USE_ODBC
|
|
return std::make_unique<ODBCColumnsInfoHandler>(keep_alive_timeout, context);
|
|
#else
|
|
return nullptr;
|
|
#endif
|
|
else if (uri.getPath() == "/identifier_quote")
|
|
#if USE_ODBC
|
|
return std::make_unique<IdentifierQuoteHandler>(keep_alive_timeout, context);
|
|
#else
|
|
return nullptr;
|
|
#endif
|
|
else if (uri.getPath() == "/schema_allowed")
|
|
#if USE_ODBC
|
|
return std::make_unique<SchemaAllowedHandler>(keep_alive_timeout, context);
|
|
#else
|
|
return nullptr;
|
|
#endif
|
|
else if (uri.getPath() == "/write")
|
|
return std::make_unique<ODBCHandler>(pool_map, keep_alive_timeout, context, "write");
|
|
else
|
|
return std::make_unique<ODBCHandler>(pool_map, keep_alive_timeout, context, "read");
|
|
}
|
|
return nullptr;
|
|
}
|
|
}
|