1
0
mirror of synced 2025-04-26 14:28:51 +03:00

Changed test and README to use the generic lambda.

This commit is contained in:
yhirose 2014-03-31 21:07:56 -04:00
parent 5c01c69223
commit 98e3e7b3c1
3 changed files with 10 additions and 10 deletions

View File

@ -20,7 +20,7 @@ Inspired by [Sinatra](http://www.sinatrarb.com/) and [express](https://github.co
Server svr;
svr.get("/hi", [](const Request& req, Response& res) {
svr.get("/hi", [](const auto& req, auto& res) {
res.set_content("Hello World!", "text/plain");
});
@ -43,4 +43,4 @@ Client Example
}
}
Copyright (c) 2012 Yuji Hirose. All rights reserved.
Copyright (c) 2014 Yuji Hirose. All rights reserved.

View File

@ -3,10 +3,10 @@ USE_CLANG = 1
ifdef USE_CLANG
CC = clang++
CCFLAGS = -std=c++0x -stdlib=libc++ -g -DGTEST_USE_OWN_TR1_TUPLE
CCFLAGS = -std=c++1y -stdlib=libc++ -g -DGTEST_USE_OWN_TR1_TUPLE
else
CC = g++-4.7
CCFLAGS = -std=c++11 -g
CC = g++-4.9
CCFLAGS = -std=c++1y -g
endif
all : test

View File

@ -105,15 +105,15 @@ protected:
virtual void SetUp() {
svr_.set_base_dir("./www");
svr_.get("/hi", [&](const Request& req, Response& res) {
svr_.get("/hi", [&](const auto& req, auto& res) {
res.set_content("Hello World!", "text/plain");
});
svr_.get("/", [&](const Request& req, Response& res) {
svr_.get("/", [&](const auto& req, auto& res) {
res.set_redirect("/hi");
});
svr_.post("/person", [&](const Request& req, Response& res) {
svr_.post("/person", [&](const auto& req, auto& res) {
if (req.has_param("name") && req.has_param("note")) {
persons_[req.params.at("name")] = req.params.at("note");
} else {
@ -121,7 +121,7 @@ protected:
}
});
svr_.get("/person/(.*)", [&](const Request& req, Response& res) {
svr_.get("/person/(.*)", [&](const auto& req, auto& res) {
string name = req.matches[1];
if (persons_.find(name) != persons_.end()) {
auto note = persons_[name];
@ -131,7 +131,7 @@ protected:
}
});
svr_.get("/stop", [&](const Request& req, Response& res) {
svr_.get("/stop", [&](const auto& req, auto& res) {
svr_.stop();
});