2021-03-05 09:38:00 +00:00
|
|
|
#include "HandlerFactory.h"
|
|
|
|
|
|
|
|
#include <Poco/Net/HTTPServerRequest.h>
|
|
|
|
#include <common/logger_useful.h>
|
2021-03-05 15:37:43 +00:00
|
|
|
#include <Server/HTTP/HTMLForm.h>
|
2021-03-05 09:38:00 +00:00
|
|
|
#include "Handlers.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
std::unique_ptr<HTTPRequestHandler> LibraryBridgeHandlerFactory::createRequestHandler(const HTTPServerRequest & request)
|
|
|
|
{
|
|
|
|
Poco::URI uri{request.getURI()};
|
|
|
|
LOG_DEBUG(log, "Request URI: {}", uri.toString());
|
|
|
|
|
|
|
|
if (uri == "/ping" && request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET)
|
|
|
|
return std::make_unique<PingHandler>(keep_alive_timeout);
|
|
|
|
|
|
|
|
if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST)
|
|
|
|
{
|
|
|
|
/// Remove '/' in the beginning.
|
|
|
|
auto dictionary_id = uri.getPath().substr(1);
|
2021-03-06 18:21:40 +00:00
|
|
|
return std::make_unique<LibraryRequestHandler>(keep_alive_timeout, context, dictionary_id);
|
2021-03-05 09:38:00 +00:00
|
|
|
}
|
|
|
|
|
2021-03-06 18:44:40 +00:00
|
|
|
return nullptr;
|
2021-03-05 09:38:00 +00:00
|
|
|
}
|
|
|
|
}
|