72 {
73 bool requestMatched = false;
74
75 const std::string absoluteMountPath = parentMountPath + mountPoint.
relativeMountPath;
76
78
79 std::string_view mountPath;
80 std::string_view mountQueryString;
82 auto requiredQueryPairs =
parseQuery(mountQueryString);
83
84 std::string_view requestPath;
85 std::string_view requestQueryString;
87 auto requestQueryPairs =
parseQuery(requestQueryString);
88
89
90 std::string_view normalizedMountPath = mountPath;
91 std::string_view normalizedRequestPath = requestPath;
95 }
96 if (normalizedMountPath.empty()) {
97 normalizedMountPath = "/";
98 }
99
100 bool pathMatches = false;
101 if (mountPath.find(':') != std::string::npos) {
102 if (
regex.mark_count() == 0) {
103 LOG(TRACE) << "ApplicationDispatcher: precompiled regex";
105 true,
108 } else {
109 LOG(TRACE) << "ApplicationDispatcher: using precompiled regex";
110 }
112 } else {
114 }
115
117 requestMatched = (pathMatches && queryMatches);
118
119 LOG(TRACE) << controller.
getResponse()->getSocketContext()->getSocketConnection()->getConnectionName()
120 << " HTTP Express: application -> " << (requestMatched ? "MATCH" : "NO MATCH");
121 LOG(TRACE) <<
" RequestMethod: " << controller.
getRequest()->method;
122 LOG(TRACE) <<
" RequestUrl: " << controller.
getRequest()->url;
123 LOG(TRACE) <<
" RequestPath: " << controller.
getRequest()->path;
124 LOG(TRACE) << " AbsoluteMountPath: " << absoluteMountPath;
127
128 if (requestMatched) {
129 controller.
getRequest()->queries.insert(requestQueryPairs.begin(), requestQueryPairs.end());
130
133 }
134
136 }
137 } else {
138 LOG(TRACE) << controller.
getResponse()->getSocketContext()->getSocketConnection()->getConnectionName()
139 << " HTTP Express: application -> next(...) called";
140 LOG(TRACE) <<
" RequestMethod: " << controller.
getRequest()->method;
141 LOG(TRACE) <<
" RequestUrl: " << controller.
getRequest()->url;
142 LOG(TRACE) <<
" RequestPath: " << controller.
getRequest()->path;
143 LOG(TRACE) << " AbsoluteMountPath: " << absoluteMountPath;
144 }
145
146 return requestMatched;
147 }
const std::shared_ptr< Request > & getRequest()
bool getStrictRouting() const
bool getCaseInsensitiveRouting() const
const std::shared_ptr< Response > & getResponse()
std::vector< std::string > names
bool matchAndFillParams(const std::regex &rx, const std::vector< std::string > &names, std::string_view reqPath, RequestLike &req)
bool querySupersetMatches(const std::unordered_map< std::string, std::string > &rq, const std::unordered_map< std::string, std::string > &need)
void setParams(const std::string &cpath, Request &req)
void splitPathAndQuery(std::string_view url, std::string_view &path, std::string_view &query)
std::pair< std::regex, std::vector< std::string > > compileParamRegex(std::string_view mountPath, bool isPrefix, bool strictRouting, bool caseInsensitive)
std::unordered_map< std::string, std::string > parseQuery(std::string_view qs)
bool hasResult(const std::string &cpath)
std::string_view trimOneTrailingSlash(std::string_view s)
bool equalPath(std::string_view a, std::string_view b, bool caseInsensitive)
std::string relativeMountPath