Update URI filter for query endpoint once again

This commit is contained in:
Konstantin Bogdanov 2023-10-20 13:00:06 +02:00
parent b2d930652b
commit dc31963748
Signed by: thevar1able
GPG Key ID: DB399448D9FE52F1

View File

@ -182,15 +182,19 @@ void addDefaultHandlersFactory(
auto query_handler = std::make_shared<HandlingRuleHTTPHandlerFactory<DynamicQueryHandler>>(std::move(dynamic_creator)); auto query_handler = std::make_shared<HandlingRuleHTTPHandlerFactory<DynamicQueryHandler>>(std::move(dynamic_creator));
query_handler->addFilter([](const auto & request) query_handler->addFilter([](const auto & request)
{ {
bool pathMatchesGetOrHead = startsWith(request.getURI(), "/?") || startsWith(request.getURI(), "/query?"); bool path_matches_get_or_head = startsWith(request.getURI(), "?")
bool isGetOrHeadRequest = request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET || startsWith(request.getURI(), "/?")
|| request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD; || startsWith(request.getURI(), "/query?");
bool is_get_or_head_request = request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET
|| request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD;
bool pathMatchesPostOrOptions = pathMatchesGetOrHead || request.getURI() == "/"; bool path_matches_post_or_options = path_matches_get_or_head
bool isPostOrOptionsRequest = request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST || request.getURI() == "/"
|| request.getURI().empty();
bool is_post_or_options_request = request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST
|| request.getMethod() == Poco::Net::HTTPRequest::HTTP_OPTIONS; || request.getMethod() == Poco::Net::HTTPRequest::HTTP_OPTIONS;
return (pathMatchesGetOrHead && isGetOrHeadRequest) || (pathMatchesPostOrOptions && isPostOrOptionsRequest); return (path_matches_get_or_head && is_get_or_head_request) || (path_matches_post_or_options && is_post_or_options_request);
} }
); );
factory.addHandler(query_handler); factory.addHandler(query_handler);