Skip to content

Commit e3ba10d

Browse files
authored
Merge pull request #550 from lag945/examples_patch_20221021
Change one of example's routes to handle POST instead of GET.
2 parents ac757ff + 1681ff2 commit e3ba10d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

examples/example_with_all.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ int main()
8181

8282
// more json example
8383
CROW_ROUTE(app, "/add_json")
84-
([](const crow::request& req) {
85-
auto x = crow::json::load(req.body);
86-
if (!x)
87-
return crow::response(400);
88-
int sum = x["a"].i() + x["b"].i();
89-
std::ostringstream os;
90-
os << sum;
91-
return crow::response{os.str()};
92-
});
84+
.methods("POST"_method)([](const crow::request& req) {
85+
auto x = crow::json::load(req.body);
86+
if (!x)
87+
return crow::response(400);
88+
int sum = x["a"].i() + x["b"].i();
89+
std::ostringstream os;
90+
os << sum;
91+
return crow::response{os.str()};
92+
});
9393

9494
CROW_ROUTE(app, "/params")
9595
([](const crow::request& req) {

0 commit comments

Comments
 (0)