diff options
-rw-r--r-- | examples/example.cpp | 12 | ||||
-rw-r--r-- | examples/example_chat.cpp | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/examples/example.cpp b/examples/example.cpp index 056fe6a..bcaa006 100644 --- a/examples/example.cpp +++ b/examples/example.cpp @@ -62,7 +62,9 @@ int main() return "Trailing slash test case.."; }); + // simple json response + // To see it in action enter {ip}:18080/json CROW_ROUTE(app, "/json") ([]{ crow::json::wvalue x; @@ -70,6 +72,8 @@ int main() return x; }); + // To see it in action enter {ip}:18080/hello/{integer_between -2^32 and 100} and you should receive + // {integer_between -2^31 and 100} bottles of beer! CROW_ROUTE(app,"/hello/<int>") ([](int count){ if (count > 100) @@ -79,6 +83,7 @@ int main() return crow::response(os.str()); }); + // To see it in action submit {ip}:18080/add/1/2 and you should receive 3 (exciting, isn't it) CROW_ROUTE(app,"/add/<int>/<int>") ([](const crow::request& req, crow::response& res, int a, int b){ std::ostringstream os; @@ -94,6 +99,13 @@ int main() //}); // more json example + + // To see it in action, I recommend to use the Postman Chrome extension: + // * Set the address to {ip}:18080/add_json + // * Set the method to post + // * Select 'raw' and then JSON + // * Add {"a": 1, "b": 1} + // * Send and you should receive 2 CROW_ROUTE(app, "/add_json") .methods("POST"_method) ([](const crow::request& req){ diff --git a/examples/example_chat.cpp b/examples/example_chat.cpp index aa7cc96..ae031b7 100644 --- a/examples/example_chat.cpp +++ b/examples/example_chat.cpp @@ -25,7 +25,7 @@ void broadcast(const string& msg) } ress.clear(); } - +// To see how it works go on {ip}:40080 but I just got it working with external build (not directly in IDE, I guess a problem with dependency) int main() { crow::SimpleApp app; |