CROW_ROUTE(app,"/hello/<int>")([](int count){
if (count > 100) return crow::Res(400);
std::ostringstream os;
os << count << " bottles of beer!";
return crow::Res(os.str());
});
Handler arguments type check at compile time
// Compile error with message "Handler type is mismatched with URL paramters"
CROW_ROUTE(app,"/another/<int>")([](int a, int b){
return crow::Res(500);
});
Handling JSON Requests
CROW_ROUTE(app, "/add_json").methods("POST"_method)
([](const crow::Req& req){
auto x = crow::json::load(req.body);
if (!x)
return crow::Res(400);
std::ostringstream os;
os << x.dump();
return crow::Res{os.str()};
});
introduce
This is a modified version, in order to support the latest version of boost,and cross platform as well as modular development.
Requirements
Examlpe
Static reflection
server rendering
JSON Response
Arguments
Handler arguments type check at compile time
Handling JSON Requests