From 633dc82b8f8f80bf82c664120e097a2ebbcce877 Mon Sep 17 00:00:00 2001 From: Rasie1 Date: Thu, 16 Mar 2017 19:27:19 +0300 Subject: Add get_dict usage to example --- examples/example.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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()}; }); -- cgit v1.2.3-54-g00ecf