MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / match

Method match

Libraries/Http/HttpRouter.cpp:141–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141Result HttpRouter::match(HttpParser::Method method, StringSpan requestTarget, Span<HttpRouteParam> params,
142 HttpRouteMatch& match) const
143{
144 match = {};
145
146 HttpRequestTargetView target;
147 SC_TRY(target.parse(requestTarget));
148 const StringSpan requestPath = target.path;
149 bool pathMatched = false;
150 for (const HttpRoute& route : routes)
151 {
152 size_t numParams = 0;
153 const HttpRouteMatchStatus status =
154 HttpRouterInternal::matchPath(route.pathPattern, requestPath, params, numParams);
155 if (status == HttpRouteMatchStatus::TooManyParams)
156 {
157 match.status = status;
158 return Result(true);
159 }
160 if (status != HttpRouteMatchStatus::Matched)
161 {
162 continue;
163 }
164 pathMatched = true;
165 if (route.method == method)
166 {
167 match.status = HttpRouteMatchStatus::Matched;
168 match.route = &route;
169 match.numParams = numParams;
170 return Result(true);
171 }
172 }
173
174 match.status = pathMatched ? HttpRouteMatchStatus::MethodNotAllowed : HttpRouteMatchStatus::NotFound;
175 return Result(true);
176}
177
178Result HttpRouter::formatAllowHeader(StringSpan requestTarget, Span<char> storage, StringSpan& allow) const
179{

Callers 12

routeMatchingMethod · 0.45
diagnosticMessagesMethod · 0.45
onRequestMethod · 0.45
processFileRecursivelyFunction · 0.45
parse_elf_sectionsFunction · 0.45
collect_nm_countsFunction · 0.45
parse_macho_mapFunction · 0.45
parseHostMethod · 0.45
getBoundaryMethod · 0.45

Calls 2

ResultClass · 0.50
parseMethod · 0.45

Tested by 2

routeMatchingMethod · 0.36
diagnosticMessagesMethod · 0.36