summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2017-10-26 13:58:28 -0700
committerEd Tanous <ed.tanous@intel.com>2017-10-30 11:37:34 -0700
commit1c74de8786b2e16de8281abf4d427644fc426ee8 (patch)
tree6ef427337f1303953403a0359c0e826e3eb541f1 /include
parentc963aa422e35a954229c3fcf9646150dc0066369 (diff)
downloadbmcweb-1c74de8786b2e16de8281abf4d427644fc426ee8.tar.gz
bmcweb-1c74de8786b2e16de8281abf4d427644fc426ee8.zip
Update get_routes to use trie for efficiency
This commit updates the behavior of request_routes to actually use the trie data structure to find the appropriate routes. This function was originaly intended for debugging, but now with redfish, it is being used to look up routes. Also, update the prototype so it returns a string pointer to the main route in the trie instead of copying the whole list of stings. A future optimization should also give the ability to pick a "stop at" character, or a depth so that users can decide how deep into the tree they want to iterate, instead of getting the whole subtree and filtering after the fact. Change-Id: I8b98fb3f19f59a043ae6aa583ed62ab89be10eb8
Diffstat (limited to 'include')
-rw-r--r--include/redfish_v1.hpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/redfish_v1.hpp b/include/redfish_v1.hpp
index 4de009e..243ddfb 100644
--- a/include/redfish_v1.hpp
+++ b/include/redfish_v1.hpp
@@ -18,15 +18,15 @@ namespace redfish {
template <typename... Middlewares>
void get_redfish_sub_routes(Crow<Middlewares...>& app, const std::string& url,
nlohmann::json& j) {
- auto routes = app.get_routes(url);
- for (auto& route : routes) {
+ std::vector<const std::string*> routes = app.get_routes(url);
+ for (auto route : routes) {
auto redfish_sub_route =
- route.substr(url.size(), route.size() - url.size() - 1);
+ route->substr(url.size(), route->size() - url.size() - 1);
// check if the route is at this level, and we didn't find and exact match
// also, filter out resources that start with $ to remove $metadata
if (!redfish_sub_route.empty() && redfish_sub_route[0] != '$' &&
redfish_sub_route.find('/') == std::string::npos) {
- j[redfish_sub_route] = nlohmann::json{{"@odata.id", route}};
+ j[redfish_sub_route] = nlohmann::json{{"@odata.id", *route}};
}
}
}
@@ -87,6 +87,7 @@ void request_routes(Crow<Middlewares...>& app) {
}
}
*/
+
res.json_value = {
{"@odata.context",
"/redfish/v1/$metadata#ChassisCollection.ChassisCollection"},
OpenPOWER on IntegriCloud