Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions include/crow/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,25 @@ namespace crow
}

/// Create a dynamic route using a rule (**Use CROW_ROUTE instead**)
DynamicRule& route_dynamic(std::string&& rule)
DynamicRule& route_dynamic(const std::string& rule)
{
return router_.new_rule_dynamic(std::move(rule));
return router_.new_rule_dynamic(rule);
}

///Create a route using a rule (**Use CROW_ROUTE instead**)
/// Create a route using a rule (**Use CROW_ROUTE instead**)
template<uint64_t Tag>
#ifdef CROW_GCC83_WORKAROUND
auto& route(std::string&& rule)
auto& route(const std::string& rule)
#else
auto route(std::string&& rule)
auto route(const std::string& rule)
#endif
#if defined CROW_CAN_USE_CPP17 && !defined CROW_GCC83_WORKAROUND
-> typename std::invoke_result<decltype(&Router::new_rule_tagged<Tag>), Router, std::string&&>::type
-> typename std::invoke_result<decltype(&Router::new_rule_tagged<Tag>), Router, const std::string&>::type
#elif !defined CROW_GCC83_WORKAROUND
-> typename std::result_of<decltype (&Router::new_rule_tagged<Tag>)(Router, std::string&&)>::type
-> typename std::result_of<decltype (&Router::new_rule_tagged<Tag>)(Router, const std::string&)>::type
#endif
{
return router_.new_rule_tagged<Tag>(std::move(rule));
return router_.new_rule_tagged<Tag>(rule);
}

/// Create a route for any requests without a proper route (**Use CROW_CATCHALL_ROUTE instead**)
Expand Down Expand Up @@ -187,7 +187,7 @@ namespace crow
bindaddr_ = bindaddr;
return *this;
}

/// Get the address that Crow will handle requests on
std::string bindaddr()
{
Expand All @@ -208,7 +208,7 @@ namespace crow
concurrency_ = concurrency;
return *this;
}

/// Get the number of threads that server is using
std::uint16_t concurrency()
{
Expand Down
14 changes: 6 additions & 8 deletions include/crow/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -1154,25 +1154,23 @@ namespace crow
return static_dir_;
}

DynamicRule& new_rule_dynamic(std::string&& rule)
DynamicRule& new_rule_dynamic(const std::string& rule)
{
std::string new_rule = std::move(rule);
new_rule = '/' + prefix_ + new_rule;
auto ruleObject = new DynamicRule(new_rule);
std::string new_rule = '/' + prefix_ + rule;
auto ruleObject = new DynamicRule(std::move(new_rule));
ruleObject->custom_templates_base = templates_dir_;
all_rules_.emplace_back(ruleObject);

return *ruleObject;
}

template<uint64_t N>
typename black_magic::arguments<N>::type::template rebind<TaggedRule>& new_rule_tagged(std::string&& rule)
typename black_magic::arguments<N>::type::template rebind<TaggedRule>& new_rule_tagged(const std::string& rule)
{
std::string new_rule = std::move(rule);
new_rule = '/' + prefix_ + new_rule;
std::string new_rule = '/' + prefix_ + rule;
using RuleT = typename black_magic::arguments<N>::type::template rebind<TaggedRule>;

auto ruleObject = new RuleT(new_rule);
auto ruleObject = new RuleT(std::move(new_rule));
ruleObject->custom_templates_base = templates_dir_;
all_rules_.emplace_back(ruleObject);

Expand Down