Skip to content
Merged
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
33 changes: 16 additions & 17 deletions include/crow/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,6 @@ namespace crow // NOTE: Already documented in "crow/app.h"

constexpr size_t RULE_SPECIAL_REDIRECT_SLASH = 1;


/// A search tree.
class Trie
{
Expand Down Expand Up @@ -1317,7 +1316,9 @@ namespace crow // NOTE: Already documented in "crow/app.h"

ruleObject->foreach_method([&](int method) {
per_methods_[method].rules.emplace_back(ruleObject);
per_methods_[method].trie.add(rule, per_methods_[method].rules.size() - 1, BP_index != INVALID_BP_ID ? blueprints[BP_index]->prefix().length() : 0, BP_index);
per_methods_[method].trie.add(rule, per_methods_[method].rules.size() - 1,
BP_index != INVALID_BP_ID ? blueprints[BP_index]->prefix().length() : 0,
BP_index);

// directory case:
// request to '/about' url matches '/about/' rule
Expand Down Expand Up @@ -1528,11 +1529,12 @@ namespace crow // NOTE: Already documented in "crow/app.h"
CatchallRule& get_catch_all(const routing_handle_result& found) {
std::vector<Blueprint*> bps_found;
get_found_bp(found.blueprint_indices, blueprints_, bps_found);
for (int i = bps_found.size() - 1; i > 0; i--)
{
std::vector<size_t> bpi = found.blueprint_indices;
if (bps_found[i]->catchall_rule().has_handler()) {
return bps_found[i]->catchall_rule();
if (!bps_found.empty()) {
for (size_t i = bps_found.size() - 1; i > 0; i--)
{
if (bps_found[i]->catchall_rule().has_handler()) {
return bps_found[i]->catchall_rule();
}
}
}
return catchall_rule_;
Expand All @@ -1544,20 +1546,17 @@ namespace crow // NOTE: Already documented in "crow/app.h"

std::vector<Blueprint*> bps_found;
get_found_bp(found.blueprint_indices, blueprints_, bps_found);
for (int i = bps_found.size() - 1; i > 0; i--)
{
std::vector<size_t> bpi = found.blueprint_indices;
if (bps_found[i]->catchall_rule().has_handler())
{
if (!bps_found.empty()) {
for (size_t i = bps_found.size() - 1; i > 0; i--) {
if (bps_found[i]->catchall_rule().has_handler()) {
#ifdef CROW_ENABLE_DEBUG
return std::string("Redirected to Blueprint \"" + bps_found[i]->prefix() + "\" Catchall rule");
return std::string("Redirected to Blueprint \"" + bps_found[i]->prefix() + "\" Catchall rule");
#else
return EMPTY;
return EMPTY;
#endif
}
}
}
if (catchall_rule_.has_handler())
{
} else if (catchall_rule_.has_handler()) {
#ifdef CROW_ENABLE_DEBUG
return std::string("Redirected to global Catchall rule");
#else
Expand Down