diff options
author | ipknHama <ipknhama@gmail.com> | 2015-02-19 12:16:28 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2015-02-19 12:16:28 +0900 |
commit | 5d8d52763989f8839644d64791ea0a47f2b28799 (patch) | |
tree | f607871b4bd6df8f2753a336fb1b942ca6e1ab0d /include/routing.h | |
parent | c8dbd421c9c4ab44533ba702901a9ce63851b5f1 (diff) | |
download | crow-5d8d52763989f8839644d64791ea0a47f2b28799.tar.gz crow-5d8d52763989f8839644d64791ea0a47f2b28799.zip |
add run-time check for handler type for `route_dynamic`
Diffstat (limited to 'include/routing.h')
-rw-r--r-- | include/routing.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/routing.h b/include/routing.h index 6ca1a03..0c6cc61 100644 --- a/include/routing.h +++ b/include/routing.h @@ -263,6 +263,13 @@ namespace crow wrap(Func f, black_magic::seq<Indices...>) { using function_t = utility::function_traits<Func>; + if (!black_magic::is_paramter_tag_compatible( + black_magic::get_parameter_tag_runtime(rule_.c_str()), + black_magic::compute_paramater_tag_from_args_list< + typename function_t::template arg<Indices>...>::value)) + { + throw std::runtime_error("route_dynamic: Handler type is mismatched with URL paramters: " + rule_); + } auto ret = detail::routing_handler_call_helper::Wrapped<Func, typename function_t::template arg<Indices>...>(); ret.template set< typename function_t::template arg<Indices>... @@ -826,7 +833,7 @@ public: return; } - CROW_LOG_DEBUG << "Matched rule '" << (rules_[rule_index].get())->rule_ << "' " << (uint32_t)req.method << " / " << rules_[rule_index]->methods(); + CROW_LOG_DEBUG << "Matched rule '" << rules_[rule_index]->rule_ << "' " << (uint32_t)req.method << " / " << rules_[rule_index]->methods(); // any uncaught exceptions become 500s try |