summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-04-10 20:20:56 +0300
committerEd Tanous <ed@tanous.net>2023-04-27 20:18:35 +0300
commit28f4b387a0f448f0be1b746a85fc58458ece8db3 (patch)
tree74ff35f864d0a43541f29ee3e2e01736a7ed8030
parent15a42df05b033a06e38d2998511d6c79d09d66a7 (diff)
downloadbmcweb-28f4b387a0f448f0be1b746a85fc58458ece8db3.tar.xz
Remove nameStr from router
It isn't used anywhere in the code, so it can be removed, and the router simplified. These common data structures have caused problems, in that they're not copied to child handlers, and cause bugs like #249. Tested: Redfish service validator passes. Basic sanity tests of both static file routes such as $metadata (which use DynamicRule) as well as method routes, such as /redfish/v1, return valid data. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I93ad74581912e18ee5db9aaa9ecdaf08ed765418
-rw-r--r--http/routing.hpp28
1 files changed, 2 insertions, 26 deletions
diff --git a/http/routing.hpp b/http/routing.hpp
index e73297c3e4..18d3c2afd9 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -107,7 +107,6 @@ class BaseRule
std::vector<redfish::Privileges> privilegesSet;
std::string rule;
- std::string nameStr;
std::unique_ptr<BaseRule> ruleToUpgrade;
@@ -390,13 +389,6 @@ struct RuleParameterTraits
return *p;
}
- self_t& name(std::string_view name) noexcept
- {
- self_t* self = static_cast<self_t*>(this);
- self->nameStr = name;
- return *self;
- }
-
self_t& methods(boost::beast::http::verb method)
{
self_t* self = static_cast<self_t*>(this);
@@ -468,8 +460,7 @@ class DynamicRule : public BaseRule, public RuleParameterTraits<DynamicRule>
{
if (!erasedHandler)
{
- throw std::runtime_error(nameStr + (!nameStr.empty() ? ": " : "") +
- "no handler for url " + rule);
+ throw std::runtime_error("no handler for url " + rule);
}
}
@@ -508,13 +499,6 @@ class DynamicRule : public BaseRule, public RuleParameterTraits<DynamicRule>
return ret;
}
- template <typename Func>
- void operator()(std::string name, Func&& f)
- {
- nameStr = std::move(name);
- (*this).template operator()<Func>(std::forward(f));
- }
-
private:
std::function<void(const Request&,
const std::shared_ptr<bmcweb::AsyncResp>&,
@@ -537,8 +521,7 @@ class TaggedRule :
{
if (!handler)
{
- throw std::runtime_error(nameStr + (!nameStr.empty() ? ": " : "") +
- "no handler for url " + rule);
+ throw std::runtime_error("no handler for url " + rule);
}
}
@@ -562,13 +545,6 @@ class TaggedRule :
handler = std::forward<Func>(f);
}
- template <typename Func>
- void operator()(std::string_view name, Func&& f)
- {
- nameStr = name;
- (*this).template operator()<Func>(std::forward(f));
- }
-
void handle(const Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::vector<std::string>& params) override