aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAntony Woods <acron1@gmail.com>2014-10-14 09:48:35 +0100
committerAntony Woods <acron1@gmail.com>2014-10-14 09:48:35 +0100
commit06842721d7da53a2235e6e4071760588ec285f90 (patch)
treec72f69e9fe4154be039ba89e474395e21b6d5fdf /examples
parenta8f6c5a92fea5439b4a0372ccc3b367e3c3bed3b (diff)
downloadcrow-06842721d7da53a2235e6e4071760588ec285f90.tar.gz
crow-06842721d7da53a2235e6e4071760588ec285f90.zip
Wrapped qs_parse as query_string and added tests
Diffstat (limited to 'examples')
-rw-r--r--examples/example.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/examples/example.cpp b/examples/example.cpp
index 9f482af..f9d006e 100644
--- a/examples/example.cpp
+++ b/examples/example.cpp
@@ -71,14 +71,19 @@ int main()
CROW_ROUTE(app, "/params")
([](const crow::request& req){
std::ostringstream os;
- os << "Params:\n";
- for (auto& i : req.url_params) {
- os << "key = " << i.first << ", val = " << i.second << '\n';
+ os << "Params: " << req.url_params << "\n\n";
+ os << "The key 'foo' was " << (req.url_params.get("foo") == nullptr ? "not " : "") << "found.\n";
+ if(req.url_params.get("pew") != nullptr) {
+ double countD = boost::lexical_cast<double>(req.url_params.get("pew"));
+ os << "The value of 'pew' is " << countD << '\n';
+ }
+ auto count = req.url_params.get_list("count");
+ os << "The key 'count' contains " << count.size() << " value(s).\n";
+ for(const auto& countVal : count) {
+ os << " - " << countVal << '\n';
}
return crow::response{os.str()};
- });
-
-
+ });
// ignore all log
crow::logger::setLogLevel(crow::LogLevel::DEBUG);