Skip to content

Commit ac9c4c3

Browse files
committed
formatted crow
1 parent 738b81b commit ac9c4c3

1 file changed

Lines changed: 29 additions & 38 deletions

File tree

src/crow/main.cpp

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,38 @@
33

44
class a : public crow::returnable
55
{
6-
public:
7-
a() : returnable("text/plain"){};
6+
public:
7+
a() : returnable("text/plain"){};
88

9-
std::string dump() const override
10-
{
11-
return "ABCDF";
12-
}
9+
std::string dump() const override { return "ABCDF"; }
1310
};
1411

1512
int main()
1613
{
17-
constexpr uint16_t port = 8080;
18-
std::vector<int> values;
19-
crow::SimpleApp app;
20-
21-
CROW_ROUTE(app, "/")
22-
([]() {
23-
return "Hello world";
24-
});
25-
26-
CROW_ROUTE(app, "/json")
27-
([] {
28-
return crow::json::wvalue({ { "message", "Hello, World!" }, {"message2", "Hello, World.. Again!"} });
29-
});
30-
31-
CROW_ROUTE(app, "/custom")
32-
([]() {
33-
return a();
34-
});
35-
36-
CROW_ROUTE(app, "/hello/<int>").methods(crow::HTTPMethod::POST)([&values](int count) {
37-
values.push_back(count);
38-
return crow::response(std::to_string(count));
39-
});
40-
41-
CROW_ROUTE(app, "/hello/").methods(crow::HTTPMethod::GET)([&values]() {
42-
crow::json::wvalue returnValue;
43-
returnValue["values"] = values;
44-
return returnValue;
45-
});
46-
47-
app.port(port).run();
48-
return 0;
14+
constexpr uint16_t port = 8080;
15+
std::vector<int> values;
16+
crow::SimpleApp app;
17+
18+
CROW_ROUTE(app, "/")
19+
([]() { return "Hello world"; });
20+
21+
CROW_ROUTE(app, "/json")
22+
([]() { return crow::json::wvalue({ { "message", "Hello, World!" }, { "message2", "Hello, World.. Again!" } }); });
23+
24+
CROW_ROUTE(app, "/custom")
25+
([]() { return a(); });
26+
27+
CROW_ROUTE(app, "/hello/<int>").methods(crow::HTTPMethod::POST)([&values](int count) {
28+
values.push_back(count);
29+
return crow::response(std::to_string(count));
30+
});
31+
32+
CROW_ROUTE(app, "/hello/").methods(crow::HTTPMethod::GET)([&values]() {
33+
crow::json::wvalue returnValue;
34+
returnValue["values"] = values;
35+
return returnValue;
36+
});
37+
38+
app.port(port).run();
39+
return 0;
4940
}

0 commit comments

Comments
 (0)