72 {
73 bool requestMatched = false;
74
76 const std::string absoluteMountPath = parentMountPath + mountPoint.
relativeMountPath;
77
79
80 std::string_view mountPath;
81 std::string_view mountQueryString;
83 auto requiredQueryPairs =
parseQuery(mountQueryString);
84
85 std::string_view requestPath;
86 std::string_view requestQueryString;
88 auto requestQueryPairs =
parseQuery(requestQueryString);
89
90
91 std::string_view normalizedMountPath = mountPath;
92 std::string_view normalizedRequestPath = requestPath;
96 }
97 if (normalizedMountPath.empty()) {
98 normalizedMountPath = "/";
99 }
100
101 bool pathMatches = false;
102 if (mountPath.find(':') != std::string::npos) {
103 if (
regex.mark_count() == 0) {
104 LOG(TRACE) << "ApplicationDispatcher: precompiled regex";
106 true,
109 } else {
110 LOG(TRACE) << "ApplicationDispatcher: using precompiled regex";
111 }
113 } else {
115 }
116
118 requestMatched = (pathMatches && queryMatches);
119
120 LOG(TRACE) << controller.
getResponse()->getSocketContext()->getSocketConnection()->getConnectionName()
121 << " HTTP Express: application -> " << (requestMatched ? "MATCH" : "NO MATCH");
122 LOG(TRACE) <<
" RequestMethod: " << controller.
getRequest()->method;
123 LOG(TRACE) <<
" RequestUrl: " << controller.
getRequest()->url;
124 LOG(TRACE) <<
" RequestPath: " << controller.
getRequest()->path;
125 LOG(TRACE) <<
" Mountpoint Method: " << mountPoint.
method;
127 LOG(TRACE) << " Mountpoint AbsolutePath: " << absoluteMountPath;
130
131 if (requestMatched) {
132 controller.
getRequest()->queries.insert(requestQueryPairs.begin(), requestQueryPairs.end());
133
136 }
137
139 }
140 } else {
141 LOG(TRACE) << controller.
getResponse()->getSocketContext()->getSocketConnection()->getConnectionName()
142 << " HTTP Express: application -> next(...) called";
143 LOG(TRACE) <<
" RequestMethod: " << controller.
getRequest()->method;
144 LOG(TRACE) <<
" RequestUrl: " << controller.
getRequest()->url;
145 LOG(TRACE) <<
" RequestPath: " << controller.
getRequest()->path;
146 LOG(TRACE) << " AbsoluteMountPath: " << absoluteMountPath;
147 }
148 }
149
150 return requestMatched;
151 }
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