Mercurial > hg > orthanc
comparison OrthancFramework/Sources/RestApi/RestApiHierarchy.cpp @ 4330:a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 25 Nov 2020 14:39:10 +0100 |
parents | 44b53a2c0a13 |
children | 80fd140b12ba |
comparison
equal
deleted
inserted
replaced
4329:9dc0e42f868b | 4330:a01b1c9cbef4 |
---|---|
208 child->RegisterInternal(path, handler, level + 1); | 208 child->RegisterInternal(path, handler, level + 1); |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 | 212 |
213 bool RestApiHierarchy::LookupResource(IHttpHandler::Arguments& components, | 213 bool RestApiHierarchy::LookupResource(HttpToolbox::Arguments& components, |
214 const UriComponents& uri, | 214 const UriComponents& uri, |
215 IVisitor& visitor, | 215 IVisitor& visitor, |
216 size_t level) | 216 size_t level) |
217 { | 217 { |
218 if (uri.size() != 0 && | 218 if (uri.size() != 0 && |
219 level > uri.size()) | 219 level > uri.size()) |
220 { | 220 { |
221 return false; | 221 return false; |
222 } | 222 } |
223 | 223 |
224 UriComponents trailing; | 224 UriComponents trailing; |
225 | 225 |
226 // Look for an exact match on the resource of interest | 226 // Look for an exact match on the resource of interest |
227 if (uri.size() == 0 || | 227 if (uri.size() == 0 || |
228 level == uri.size()) | 228 level == uri.size()) |
229 { | 229 { |
230 if (!handlers_.IsEmpty() && | 230 if (!handlers_.IsEmpty() && |
231 visitor.Visit(handlers_, uri, components, trailing)) | 231 visitor.Visit(handlers_, uri, components, trailing)) |
232 { | 232 { |
233 return true; | 233 return true; |
249 | 249 |
250 // Try and go down in the hierarchy, using wildcard rules for children | 250 // Try and go down in the hierarchy, using wildcard rules for children |
251 for (child = wildcardChildren_.begin(); | 251 for (child = wildcardChildren_.begin(); |
252 child != wildcardChildren_.end(); ++child) | 252 child != wildcardChildren_.end(); ++child) |
253 { | 253 { |
254 IHttpHandler::Arguments subComponents = components; | 254 HttpToolbox::Arguments subComponents = components; |
255 subComponents[child->first] = uri[level]; | 255 subComponents[child->first] = uri[level]; |
256 | 256 |
257 if (child->second->LookupResource(subComponents, uri, visitor, level + 1)) | 257 if (child->second->LookupResource(subComponents, uri, visitor, level + 1)) |
258 { | 258 { |
259 return true; | 259 return true; |
418 | 418 |
419 | 419 |
420 bool RestApiHierarchy::LookupResource(const UriComponents& uri, | 420 bool RestApiHierarchy::LookupResource(const UriComponents& uri, |
421 IVisitor& visitor) | 421 IVisitor& visitor) |
422 { | 422 { |
423 IHttpHandler::Arguments components; | 423 HttpToolbox::Arguments components; |
424 return LookupResource(components, uri, visitor, 0); | 424 return LookupResource(components, uri, visitor, 0); |
425 } | 425 } |
426 | 426 |
427 | 427 |
428 | 428 |
441 { | 441 { |
442 } | 442 } |
443 | 443 |
444 virtual bool Visit(const RestApiHierarchy::Resource& resource, | 444 virtual bool Visit(const RestApiHierarchy::Resource& resource, |
445 const UriComponents& uri, | 445 const UriComponents& uri, |
446 const IHttpHandler::Arguments& components, | 446 const HttpToolbox::Arguments& components, |
447 const UriComponents& trailing) | 447 const UriComponents& trailing) |
448 { | 448 { |
449 if (trailing.size() == 0) // Ignore universal handlers | 449 if (trailing.size() == 0) // Ignore universal handlers |
450 { | 450 { |
451 if (resource.HasHandler(HttpMethod_Get)) | 451 if (resource.HasHandler(HttpMethod_Get)) |
475 } | 475 } |
476 | 476 |
477 void RestApiHierarchy::GetAcceptedMethods(std::set<HttpMethod>& methods, | 477 void RestApiHierarchy::GetAcceptedMethods(std::set<HttpMethod>& methods, |
478 const UriComponents& uri) | 478 const UriComponents& uri) |
479 { | 479 { |
480 IHttpHandler::Arguments components; | 480 HttpToolbox::Arguments components; |
481 AcceptedMethodsVisitor visitor(methods); | 481 AcceptedMethodsVisitor visitor(methods); |
482 if (LookupResource(components, uri, visitor, 0)) | 482 if (LookupResource(components, uri, visitor, 0)) |
483 { | 483 { |
484 Json::Value d; | 484 Json::Value d; |
485 if (GetDirectory(d, uri)) | 485 if (GetDirectory(d, uri)) |