|
|
@ -156,7 +156,7 @@ namespace crow
|
|
|
|
struct Wrapped
|
|
|
|
struct Wrapped
|
|
|
|
{
|
|
|
|
{
|
|
|
|
template <typename ... Args>
|
|
|
|
template <typename ... Args>
|
|
|
|
void set(Func f, typename std::enable_if<
|
|
|
|
void set2(Func f, typename std::enable_if<
|
|
|
|
!std::is_same<typename std::tuple_element<0, std::tuple<Args..., void>>::type, const request&>::value
|
|
|
|
!std::is_same<typename std::tuple_element<0, std::tuple<Args..., void>>::type, const request&>::value
|
|
|
|
, int>::type = 0)
|
|
|
|
, int>::type = 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -190,7 +190,7 @@ namespace crow
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename ... Args>
|
|
|
|
template <typename ... Args>
|
|
|
|
void set(Func f, typename std::enable_if<
|
|
|
|
void set2(Func f, typename std::enable_if<
|
|
|
|
std::is_same<typename std::tuple_element<0, std::tuple<Args..., void>>::type, const request&>::value &&
|
|
|
|
std::is_same<typename std::tuple_element<0, std::tuple<Args..., void>>::type, const request&>::value &&
|
|
|
|
!std::is_same<typename std::tuple_element<1, std::tuple<Args..., void, void>>::type, response&>::value
|
|
|
|
!std::is_same<typename std::tuple_element<1, std::tuple<Args..., void, void>>::type, response&>::value
|
|
|
|
, int>::type = 0)
|
|
|
|
, int>::type = 0)
|
|
|
@ -205,7 +205,7 @@ namespace crow
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <typename ... Args>
|
|
|
|
template <typename ... Args>
|
|
|
|
void set(Func f, typename std::enable_if<
|
|
|
|
void set2(Func f, typename std::enable_if<
|
|
|
|
std::is_same<typename std::tuple_element<0, std::tuple<Args..., void>>::type, const request&>::value &&
|
|
|
|
std::is_same<typename std::tuple_element<0, std::tuple<Args..., void>>::type, const request&>::value &&
|
|
|
|
std::is_same<typename std::tuple_element<1, std::tuple<Args..., void, void>>::type, response&>::value
|
|
|
|
std::is_same<typename std::tuple_element<1, std::tuple<Args..., void, void>>::type, response&>::value
|
|
|
|
, int>::type = 0)
|
|
|
|
, int>::type = 0)
|
|
|
@ -389,32 +389,30 @@ namespace crow
|
|
|
|
// enable_if Arg1 == request && Arg2 == response
|
|
|
|
// enable_if Arg1 == request && Arg2 == response
|
|
|
|
// enable_if Arg1 == request && Arg2 != resposne
|
|
|
|
// enable_if Arg1 == request && Arg2 != resposne
|
|
|
|
// enable_if Arg1 != request
|
|
|
|
// enable_if Arg1 != request
|
|
|
|
//#ifdef CROW_MSVC_WORKAROUND
|
|
|
|
#ifdef CROW_MSVC_WORKAROUND
|
|
|
|
// template <typename Func, size_t ... Indices>
|
|
|
|
template <typename Func, size_t ... Indices>
|
|
|
|
//#else
|
|
|
|
#else
|
|
|
|
// template <typename Func, unsigned ... Indices>
|
|
|
|
template <typename Func, unsigned ... Indices>
|
|
|
|
//#endif
|
|
|
|
#endif
|
|
|
|
// std::function<void(const request&, response&, const routing_params&)>
|
|
|
|
std::function<void(const request&, response&, const routing_params&)>
|
|
|
|
// wrap(Func f, black_magic::seq<Indices...>)
|
|
|
|
wrap(Func f, black_magic::seq<Indices...>)
|
|
|
|
// {
|
|
|
|
{
|
|
|
|
//#ifdef CROW_MSVC_WORKAROUND
|
|
|
|
#ifdef CROW_MSVC_WORKAROUND
|
|
|
|
// using function_t = utility::function_traits<decltype(&Func::operator())>;
|
|
|
|
using function_t = utility::function_traits<decltype(&Func::operator())>;
|
|
|
|
//#else
|
|
|
|
#else
|
|
|
|
// using function_t = utility::function_traits<Func>;
|
|
|
|
using function_t = utility::function_traits<Func>;
|
|
|
|
//#endif
|
|
|
|
#endif
|
|
|
|
// if (!black_magic::is_parameter_tag_compatible(
|
|
|
|
if (!black_magic::is_parameter_tag_compatible(
|
|
|
|
// black_magic::get_parameter_tag_runtime(rule_.c_str()),
|
|
|
|
black_magic::get_parameter_tag_runtime(rule_.c_str()),
|
|
|
|
// black_magic::compute_parameter_tag_from_args_list<
|
|
|
|
black_magic::compute_parameter_tag_from_args_list<
|
|
|
|
// typename function_t::template arg<Indices>...>::value))
|
|
|
|
typename function_t::template arg<Indices>...>::value))
|
|
|
|
// {
|
|
|
|
{
|
|
|
|
// throw std::runtime_error("route_dynamic: Handler type is mismatched with URL parameters: " + rule_);
|
|
|
|
throw std::runtime_error("route_dynamic: Handler type is mismatched with URL parameters: " + rule_);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// auto ret = detail::routing_handler_call_helper::Wrapped<Func, typename function_t::template arg<Indices>...>();
|
|
|
|
auto ret = detail::routing_handler_call_helper::Wrapped<Func, typename function_t::template arg<Indices>...>();
|
|
|
|
// ret.template set<
|
|
|
|
ret.template set2<typename function_t::template arg<Indices>...>(std::move(f));
|
|
|
|
// typename function_t::template arg<Indices>...
|
|
|
|
return ret;
|
|
|
|
// >(std::move(f));
|
|
|
|
}
|
|
|
|
// return ret;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Func>
|
|
|
|
template <typename Func>
|
|
|
|
void operator()(std::string name, Func&& f)
|
|
|
|
void operator()(std::string name, Func&& f)
|
|
|
|