Changed test and README to use the generic lambda.
This commit is contained in:
parent
5c01c69223
commit
98e3e7b3c1
@ -20,7 +20,7 @@ Inspired by [Sinatra](http://www.sinatrarb.com/) and [express](https://github.co
|
|||||||
|
|
||||||
Server svr;
|
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");
|
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.
|
||||||
|
@ -3,10 +3,10 @@ USE_CLANG = 1
|
|||||||
|
|
||||||
ifdef USE_CLANG
|
ifdef USE_CLANG
|
||||||
CC = 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
|
else
|
||||||
CC = g++-4.7
|
CC = g++-4.9
|
||||||
CCFLAGS = -std=c++11 -g
|
CCFLAGS = -std=c++1y -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all : test
|
all : test
|
||||||
|
10
test/test.cc
10
test/test.cc
@ -105,15 +105,15 @@ protected:
|
|||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
svr_.set_base_dir("./www");
|
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");
|
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");
|
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")) {
|
if (req.has_param("name") && req.has_param("note")) {
|
||||||
persons_[req.params.at("name")] = req.params.at("note");
|
persons_[req.params.at("name")] = req.params.at("note");
|
||||||
} else {
|
} 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];
|
string name = req.matches[1];
|
||||||
if (persons_.find(name) != persons_.end()) {
|
if (persons_.find(name) != persons_.end()) {
|
||||||
auto note = persons_[name];
|
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();
|
svr_.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user