CodeCommitsIssuesPull requestsActionsInsightsSecurity
4364bff3bc805ef630b8cd0bc0c8e55b27cba032

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

programs/odbc-bridge/HandlerFactory.cpp

46lines · modecode

1#include "HandlerFactory.h"
2#include "PingHandler.h"
3#include "ColumnInfoHandler.h"
4#include <Poco/URI.h>
5#include <Poco/Net/HTTPServerRequest.h>
6#include <common/logger_useful.h>
7
8namespace DB
9{
10Poco::Net::HTTPRequestHandler * HandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & request)
11{
12 Poco::URI uri{request.getURI()};
13 LOG_TRACE(log, "Request URI: {}", uri.toString());
14
15 if (uri.getPath() == "/ping" && request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET)
16 return new PingHandler(keep_alive_timeout);
17
18 if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST)
19 {
20
21 if (uri.getPath() == "/columns_info")
22#if USE_ODBC
23 return new ODBCColumnsInfoHandler(keep_alive_timeout, context);
24#else
25 return nullptr;
26#endif
27 else if (uri.getPath() == "/identifier_quote")
28#if USE_ODBC
29 return new IdentifierQuoteHandler(keep_alive_timeout, context);
30#else
31 return nullptr;
32#endif
33 else if (uri.getPath() == "/schema_allowed")
34#if USE_ODBC
35 return new SchemaAllowedHandler(keep_alive_timeout, context);
36#else
37 return nullptr;
38#endif
39 else if (uri.getPath() == "/write")
40 return new ODBCHandler(pool_map, keep_alive_timeout, context, "write");
41 else
42 return new ODBCHandler(pool_map, keep_alive_timeout, context, "read");
43 }
44 return nullptr;
45}
46}