crowsite/libs/crow/tests/external_definition/main.cpp

26 lines
557 B
C++
Raw Permalink Normal View History

2023-08-25 03:48:59 -04:00
// 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();
}