From abbc4423cfa46aecf7a12b7c99d1f7f143f6a0c0 Mon Sep 17 00:00:00 2001 From: Chunting Gu Date: Fri, 6 Sep 2019 17:44:08 +0800 Subject: [PATCH 1/2] Update book server example. --- README.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 355944c..d8cf091 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ int main() { } ``` -### Book Store +### Book Server Suppose you want to create a book server and provide the following operations with RESTful API: @@ -217,11 +217,9 @@ public: if (request->method() == "GET") { return Get(request); } - if (request->method() == "POST") { return Post(request); } - return {}; } @@ -238,23 +236,18 @@ private: Other operations are implemented by `BookDetailView`: ```cpp -// The URL is like '/books/{BookID}', and the 'args' parameter contains -// the matched book ID. class BookDetailView : public webcc::View { public: webcc::ResponsePtr Handle(webcc::RequestPtr request) override { if (request->method() == "GET") { return Get(request); } - if (request->method() == "PUT") { return Put(request); } - if (request->method() == "DELETE") { return Delete(request); } - return {}; } @@ -323,4 +316,4 @@ int main(int argc, char* argv[]) { return 0; ``` -Please see [examples/rest_book_server.cc](https://github.com/sprinfall/webcc/tree/master/examples/rest_book_server.cc) for more details. +Please see [examples/book_server](https://github.com/sprinfall/webcc/tree/master/examples/book_server) for more details. From a5358952cef54b1f67eba0be7a6e6ce28b740c3b Mon Sep 17 00:00:00 2001 From: Chunting Gu Date: Fri, 6 Sep 2019 17:45:35 +0800 Subject: [PATCH 2/2] Update book server example --- README_zh_CN.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README_zh_CN.md b/README_zh_CN.md index 79c0244..948554b 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -204,7 +204,7 @@ int main() { 下面看一个更复杂的例子。 -### 在线书店 +### Book Server 假定你想创建一个关于书的服务,提供下面这些 REST API: @@ -227,11 +227,9 @@ public: if (request->method() == "GET") { return Get(request); } - if (request->method() == "POST") { return Post(request); } - return {}; } @@ -253,15 +251,12 @@ public: if (request->method() == "GET") { return Get(request); } - if (request->method() == "PUT") { return Put(request); } - if (request->method() == "DELETE") { return Delete(request); } - return {}; } @@ -335,4 +330,4 @@ int main(int argc, char* argv[]) { } ``` -完整实现请见 [examples/rest_book_server.cc](https://github.com/sprinfall/webcc/tree/master/examples/rest_book_server.cc)。 +完整实现请见 [examples/book_server](https://github.com/sprinfall/webcc/tree/master/examples/book_server)。