diff options
author | Laurent Meyer <laurent@moid.de> | 2015-02-22 15:23:05 +0100 |
---|---|---|
committer | Laurent Meyer <laurent@moid.de> | 2015-02-22 15:23:05 +0100 |
commit | cc33f580eec4a8f9f9d646c12ffca6d20bfb1bb0 (patch) | |
tree | 2e113e84a60181019efe778b48aa81fdefe33198 /examples/example.cpp | |
parent | 4edc907fde52188df1cdd8bbca40a90dc0139cb1 (diff) | |
download | crow-cc33f580eec4a8f9f9d646c12ffca6d20bfb1bb0.tar.gz crow-cc33f580eec4a8f9f9d646c12ffca6d20bfb1bb0.zip |
Commented the examples to be easier to be understood by someone new to it.
Diffstat (limited to 'examples/example.cpp')
-rw-r--r-- | examples/example.cpp | 12 |
1 files changed, 12 insertions, 0 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){ |