aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasie1 <rasielll@gmail.com>2017-03-16 19:27:19 +0300
committerRasie1 <rasielll@gmail.com>2017-03-16 19:27:19 +0300
commit633dc82b8f8f80bf82c664120e097a2ebbcce877 (patch)
treeb1dc96d806ffb2f312650bdf8c69fb379fc5bbf1
parent01b21296bcd855cc851417ab704081c49c1b7c90 (diff)
downloadcrow-633dc82b8f8f80bf82c664120e097a2ebbcce877.tar.gz
crow-633dc82b8f8f80bf82c664120e097a2ebbcce877.zip
Add get_dict usage to example
-rw-r--r--examples/example.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/example.cpp b/examples/example.cpp
index b4cbe40..87231a2 100644
--- a/examples/example.cpp
+++ b/examples/example.cpp
@@ -146,6 +146,15 @@ int main()
for(const auto& countVal : count) {
os << " - " << countVal << '\n';
}
+
+ // To get a dictionary from the request
+ // You have to submit something like '/params?mydict[a]=b&mydict[abcd]=42' to have a list of pairs ((a, b) and (abcd, 42))
+ auto mydict = req.url_params.get_dict("mydict");
+ os << "The key 'dict' contains " << mydict.size() << " value(s).\n";
+ for(const auto& mydictVal : mydict) {
+ os << " - " << mydictVal.first << " -> " << mydictVal.second << '\n';
+ }
+
return crow::response{os.str()};
});