mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
recieve response without request being another argument in handle
This commit is contained in:
parent
b140cdf58b
commit
a7c74c6327
@ -13,12 +13,11 @@ struct ExampleMiddleware
|
||||
{
|
||||
std::string message;
|
||||
|
||||
ExampleMiddleware()
|
||||
ExampleMiddleware() : message(std::string("foo"))
|
||||
{
|
||||
message = "foo";
|
||||
}
|
||||
|
||||
void setMessage(std::string newMsg)
|
||||
void setMessage(const std::string &newMsg)
|
||||
{
|
||||
message = newMsg;
|
||||
}
|
||||
|
@ -13,12 +13,11 @@ struct ExampleMiddleware
|
||||
{
|
||||
std::string message;
|
||||
|
||||
ExampleMiddleware()
|
||||
ExampleMiddleware() : message(std::string("foo"))
|
||||
{
|
||||
message = "foo";
|
||||
}
|
||||
|
||||
void setMessage(std::string newMsg)
|
||||
void setMessage(const std::string &newMsg)
|
||||
{
|
||||
message = newMsg;
|
||||
}
|
||||
|
@ -124,6 +124,11 @@ namespace crow
|
||||
}
|
||||
}
|
||||
|
||||
void end(const int& _code) {
|
||||
code = _code;
|
||||
end();
|
||||
}
|
||||
|
||||
/// Same as end() except it adds a body part right before ending.
|
||||
void end(const std::string& body_part)
|
||||
{
|
||||
|
@ -516,7 +516,33 @@ namespace crow
|
||||
template <typename Func>
|
||||
typename std::enable_if<
|
||||
!black_magic::CallHelper<Func, black_magic::S<Args...>>::value &&
|
||||
!black_magic::CallHelper<Func, black_magic::S<crow::request, Args...>>::value,
|
||||
!black_magic::CallHelper<Func, black_magic::S<crow::request, Args...>>::value &&
|
||||
black_magic::CallHelper<Func, black_magic::S<crow::response&, Args...>>::value,
|
||||
void>::type
|
||||
operator()(Func&& f)
|
||||
{
|
||||
static_assert(black_magic::CallHelper<Func, black_magic::S<Args...>>::value ||
|
||||
black_magic::CallHelper<Func, black_magic::S<crow::response&, Args...>>::value
|
||||
,
|
||||
"Handle type is mismatched with URL parameters");
|
||||
static_assert(std::is_same<void, decltype(f(std::declval<crow::response&>(), std::declval<Args>()...))>::value,
|
||||
"Handler function with response argument should have void return type");
|
||||
|
||||
handler_ = (
|
||||
#ifdef CROW_CAN_USE_CPP14
|
||||
[f = std::move(f)]
|
||||
#else
|
||||
[f]
|
||||
#endif
|
||||
(const crow::request& req, crow::response& res, Args ... args) {
|
||||
f(res, args...);
|
||||
});
|
||||
}
|
||||
template <typename Func>
|
||||
typename std::enable_if<
|
||||
!black_magic::CallHelper<Func, black_magic::S<Args...>>::value&&
|
||||
!black_magic::CallHelper<Func, black_magic::S<crow::request, Args...>>::value &&
|
||||
!black_magic::CallHelper<Func, black_magic::S<crow::response, Args...>>::value,
|
||||
void>::type
|
||||
operator()(Func&& f)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user