mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Merge branch 'master' into keepalive_WebSocket
This commit is contained in:
commit
4fde964b82
@ -30,7 +30,7 @@
|
|||||||
#else
|
#else
|
||||||
#define CROW_ROUTE(app, url) app.template route<crow::black_magic::get_parameter_tag(url)>(url)
|
#define CROW_ROUTE(app, url) app.template route<crow::black_magic::get_parameter_tag(url)>(url)
|
||||||
#define CROW_BP_ROUTE(blueprint, url) blueprint.new_rule_tagged<crow::black_magic::get_parameter_tag(url)>(url)
|
#define CROW_BP_ROUTE(blueprint, url) blueprint.new_rule_tagged<crow::black_magic::get_parameter_tag(url)>(url)
|
||||||
#define CROW_WEBSOCKET_ROUTE(app, url) app.route<crow::black_magic::get_parameter_tag(url)>(url).websocket<decltype(app)>(&app)
|
#define CROW_WEBSOCKET_ROUTE(app, url) app.route<crow::black_magic::get_parameter_tag(url)>(url).websocket<std::remove_reference<decltype(app)>::type>(&app)
|
||||||
#define CROW_MIDDLEWARES(app, ...) template middlewares<typename std::remove_reference<decltype(app)>::type, __VA_ARGS__>()
|
#define CROW_MIDDLEWARES(app, ...) template middlewares<typename std::remove_reference<decltype(app)>::type, __VA_ARGS__>()
|
||||||
#endif
|
#endif
|
||||||
#define CROW_CATCHALL_ROUTE(app) app.catchall_route()
|
#define CROW_CATCHALL_ROUTE(app) app.catchall_route()
|
||||||
|
@ -1653,7 +1653,7 @@ namespace crow
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(__APPLE__) || defined(__MACH__)
|
#if defined(__APPLE__) || defined(__MACH__) || defined (__FreeBSD__)
|
||||||
o = std::unique_ptr<object>(new object(initializer_list));
|
o = std::unique_ptr<object>(new object(initializer_list));
|
||||||
#else
|
#else
|
||||||
(*o) = initializer_list;
|
(*o) = initializer_list;
|
||||||
@ -1672,7 +1672,7 @@ namespace crow
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(__APPLE__) || defined(__MACH__)
|
#if defined(__APPLE__) || defined(__MACH__) || defined (__FreeBSD__)
|
||||||
o = std::unique_ptr<object>(new object(value));
|
o = std::unique_ptr<object>(new object(value));
|
||||||
#else
|
#else
|
||||||
(*o) = value;
|
(*o) = value;
|
||||||
|
@ -18,6 +18,7 @@ endif()
|
|||||||
|
|
||||||
add_subdirectory(template)
|
add_subdirectory(template)
|
||||||
add_subdirectory(multi_file)
|
add_subdirectory(multi_file)
|
||||||
|
add_subdirectory(external_definition)
|
||||||
if ("ssl" IN_LIST CROW_FEATURES)
|
if ("ssl" IN_LIST CROW_FEATURES)
|
||||||
add_subdirectory(ssl)
|
add_subdirectory(ssl)
|
||||||
endif()
|
endif()
|
||||||
|
16
tests/external_definition/CMakeLists.txt
Normal file
16
tests/external_definition/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
project(test_external_definition)
|
||||||
|
|
||||||
|
add_executable(
|
||||||
|
${PROJECT_NAME}
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
${PROJECT_NAME}
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
${PROJECT_NAME}
|
||||||
|
PUBLIC Crow::Crow
|
||||||
|
)
|
25
tests/external_definition/main.cpp
Normal file
25
tests/external_definition/main.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Testing whether crow routes can be defined in an external function.
|
||||||
|
#include "crow.h"
|
||||||
|
|
||||||
|
void define_endpoints(crow::SimpleApp& app)
|
||||||
|
{
|
||||||
|
CROW_ROUTE(app, "/")
|
||||||
|
([]() {
|
||||||
|
return "Hello, world!";
|
||||||
|
});
|
||||||
|
CROW_WEBSOCKET_ROUTE(app, "/ws")
|
||||||
|
.onaccept([&](const crow::request&, void**) {
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.onopen([](crow::websocket::connection&) {})
|
||||||
|
.onclose([](crow::websocket::connection&, const std::string&) {});
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
crow::SimpleApp app;
|
||||||
|
|
||||||
|
define_endpoints(app);
|
||||||
|
|
||||||
|
app.port(18080).run();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user