aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/example.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/examples/example.cpp b/examples/example.cpp
index b360adb..f9d006e 100644
--- a/examples/example.cpp
+++ b/examples/example.cpp
@@ -68,8 +68,25 @@ int main()
return crow::response{os.str()};
});
+ CROW_ROUTE(app, "/params")
+ ([](const crow::request& req){
+ std::ostringstream os;
+ 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::CRITICAL);
+ crow::logger::setLogLevel(crow::LogLevel::DEBUG);
//crow::logger::setHandler(std::make_shared<ExampleLogHandler>());
app.port(18080)