MCPcopy Create free account
hub / github.com/MITK/MITK / ParseNodeQueryParams

Method ParseNodeQueryParams

Modules/RESTAPI/src/mitkDataStorageController.cpp:504–657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502}
503
504NodeQueryParams DataStorageController::ParseNodeQueryParams(const httplib::Request& req) const
505{
506 NodeQueryParams params;
507
508 // Pagination
509 if (req.has_param("limit"))
510 {
511 try
512 {
513 params.limit = std::stoi(req.get_param_value("limit"));
514 params.limit = std::clamp(params.limit, 1, 1000);
515 }
516 catch (const std::exception&) {}
517 }
518
519 if (req.has_param("offset"))
520 {
521 try
522 {
523 params.offset = std::max(0, std::stoi(req.get_param_value("offset")));
524 }
525 catch (const std::exception&) {}
526 }
527
528 // Hierarchy (per API spec: "all" or "toplevel" -- closed enum, strict)
529 if (req.has_param("hierarchy"))
530 {
531 const std::string hierarchyStr = req.get_param_value("hierarchy");
532 if (hierarchyStr == "all")
533 {
534 params.hierarchy = Hierarchy::All;
535 }
536 else if (hierarchyStr == "toplevel")
537 {
538 params.hierarchy = Hierarchy::Toplevel;
539 }
540 else
541 {
542 throw InvalidQueryParam{
543 "Invalid hierarchy '" + hierarchyStr + "'. Must be 'all' or 'toplevel'."};
544 }
545 }
546
547 // Path filter
548 if (req.has_param("path"))
549 {
550 params.path = req.get_param_value("path");
551 }
552
553 // Data type filter
554 if (req.has_param("data_type"))
555 {
556 params.dataType = req.get_param_value("data_type");
557 }
558
559 // Parent UID filter
560 if (req.has_param("parent_uid"))
561 {

Callers 2

HandleGET_nodesMethod · 0.95

Calls 4

ParseCommaSeparatedListFunction · 0.85
backMethod · 0.80
frontMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected