updated catchall to use references instead of pointers

This commit is contained in:
The-EDev 2021-04-12 10:41:55 +03:00
parent f779a0f8a4
commit 16ae11a4e3
2 changed files with 6 additions and 6 deletions

View File

@ -26,7 +26,7 @@
#else
#define CROW_ROUTE(app, url) app.route<crow::black_magic::get_parameter_tag(url)>(url)
#endif
#define CROW_CATCHALL_ROUTE(app) (*(app.catchall_route()))
#define CROW_CATCHALL_ROUTE(app) app.catchall_route()
namespace crow
{
@ -88,7 +88,7 @@ namespace crow
}
///Create a route for any requests without a proper route (**Use CROW_CATCHALL_ROUTE instead**)
CatchallRule* catchall_route()
CatchallRule& catchall_route()
{
return router_.catchall_rule();
}

View File

@ -1057,7 +1057,7 @@ namespace crow
return *ruleObject;
}
CatchallRule* catchall_rule()
CatchallRule& catchall_rule()
{
return catchall_rule_;
}
@ -1260,10 +1260,10 @@ namespace crow
}
}
if (catchall_rule_->has_handler())
if (catchall_rule_.has_handler())
{
CROW_LOG_DEBUG << "Cannot match rules " << req.url << ". Redirecting to Catchall rule";
catchall_rule_->handler_(req, res);
catchall_rule_.handler_(req, res);
}
else
{
@ -1328,7 +1328,7 @@ namespace crow
}
private:
CatchallRule* catchall_rule_ = new CatchallRule();
CatchallRule catchall_rule_;
struct PerMethod
{