Added Context struct.

This commit is contained in:
yhirose 2012-09-24 07:57:09 -04:00
parent 3464386f17
commit 277d7c0854
2 changed files with 66 additions and 33 deletions

View file

@ -14,17 +14,17 @@ int main(void)
Server svr;
svr.post("/", [](const Request& /*req*/, Response& res) {
res.body_ = "<html><head></head><body><ul></ul></body></html>";
svr.get("/", [](Context& cxt) {
cxt.response.body = "<html><head></head><body><ul></ul></body></html>";
});
svr.post("/item", [](const Request& req, Response& res) {
res.body_ = req.pattern_;
svr.post("/item", [](Context& cxt) {
cxt.response.body = cxt.request.pattern;
});
svr.get("/item/:name", [](const Request& req, Response& res) {
svr.get("/item/:name", [](Context& cxt) {
try {
res.body_ = req.params_.at("name");
cxt.response.body = cxt.request.params.at("name");
} catch (...) {
// Error...
}