Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

if (APPLE)
else()
find_package(Tcmalloc)
endif()
find_package(Threads)
find_package(OpenSSL)

Expand Down
5 changes: 5 additions & 0 deletions include/crow/http_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ namespace crow
}
}

void end(const int &_code) {
code = _code;
end();
}

void end(const std::string& body_part)
{
body += body_part;
Expand Down
28 changes: 27 additions & 1 deletion include/crow/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
,
"Handler 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)
{
Expand Down
9 changes: 7 additions & 2 deletions include/crow/socket_adaptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include <boost/asio/ssl.hpp>
#endif
#include "crow/settings.h"
#if BOOST_VERSION >= 107000
#define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context())
#else
#define GET_IO_SERVICE(s) ((s).get_io_service())
#endif
namespace crow
{
using namespace boost;
Expand All @@ -19,7 +24,7 @@ namespace crow

boost::asio::io_service& get_io_service()
{
return socket_.get_io_service();
return GET_IO_SERVICE(socket_);
}

tcp::socket& raw_socket()
Expand Down Expand Up @@ -96,7 +101,7 @@ namespace crow

boost::asio::io_service& get_io_service()
{
return raw_socket().get_io_service();
return GET_IO_SERVICE(raw_socket());
}

template <typename F>
Expand Down