diff --git a/CMakeLists.txt b/CMakeLists.txt index 40d53f8b4..b1b4bebae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/include/crow/http_response.h b/include/crow/http_response.h index 794017479..28cfb4b4a 100644 --- a/include/crow/http_response.h +++ b/include/crow/http_response.h @@ -110,6 +110,11 @@ namespace crow } } + void end(const int &_code) { + code = _code; + end(); + } + void end(const std::string& body_part) { body += body_part; diff --git a/include/crow/routing.h b/include/crow/routing.h index 83c43e820..ea232db00 100644 --- a/include/crow/routing.h +++ b/include/crow/routing.h @@ -516,7 +516,33 @@ namespace crow template typename std::enable_if< !black_magic::CallHelper>::value && - !black_magic::CallHelper>::value, + !black_magic::CallHelper>::value && + black_magic::CallHelper>::value, + void>::type + operator()(Func&& f) + { + static_assert(black_magic::CallHelper>::value || + black_magic::CallHelper>::value + , + "Handler type is mismatched with URL parameters"); + static_assert(std::is_same(), std::declval()...))>::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 std::enable_if< + !black_magic::CallHelper>::value && + !black_magic::CallHelper>::value && + !black_magic::CallHelper>::value, void>::type operator()(Func&& f) { diff --git a/include/crow/socket_adaptors.h b/include/crow/socket_adaptors.h index 901117f97..4bbc35c64 100644 --- a/include/crow/socket_adaptors.h +++ b/include/crow/socket_adaptors.h @@ -4,6 +4,11 @@ #include #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; @@ -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() @@ -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