mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Merge pull request #550 from lag945/examples_patch_20221021
Change one of example's routes to handle POST instead of GET.
This commit is contained in:
commit
e3ba10df18
@ -81,15 +81,15 @@ int main()
|
||||
|
||||
// more json example
|
||||
CROW_ROUTE(app, "/add_json")
|
||||
([](const crow::request& req) {
|
||||
auto x = crow::json::load(req.body);
|
||||
if (!x)
|
||||
return crow::response(400);
|
||||
int sum = x["a"].i() + x["b"].i();
|
||||
std::ostringstream os;
|
||||
os << sum;
|
||||
return crow::response{os.str()};
|
||||
});
|
||||
.methods("POST"_method)([](const crow::request& req) {
|
||||
auto x = crow::json::load(req.body);
|
||||
if (!x)
|
||||
return crow::response(400);
|
||||
int sum = x["a"].i() + x["b"].i();
|
||||
std::ostringstream os;
|
||||
os << sum;
|
||||
return crow::response{os.str()};
|
||||
});
|
||||
|
||||
CROW_ROUTE(app, "/params")
|
||||
([](const crow::request& req) {
|
||||
|
Loading…
Reference in New Issue
Block a user