aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLaurent Meyer <laurent@moid.de>2015-02-22 15:23:05 +0100
committerLaurent Meyer <laurent@moid.de>2015-02-22 15:23:05 +0100
commitcc33f580eec4a8f9f9d646c12ffca6d20bfb1bb0 (patch)
tree2e113e84a60181019efe778b48aa81fdefe33198 /examples
parent4edc907fde52188df1cdd8bbca40a90dc0139cb1 (diff)
downloadcrow-cc33f580eec4a8f9f9d646c12ffca6d20bfb1bb0.tar.gz
crow-cc33f580eec4a8f9f9d646c12ffca6d20bfb1bb0.zip
Commented the examples to be easier to be understood by someone new to it.
Diffstat (limited to 'examples')
-rw-r--r--examples/example.cpp12
-rw-r--r--examples/example_chat.cpp2
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;