Update the example in README.md.

master
Chunting Gu 7 years ago
parent 294cc74535
commit c0b61a31a2

@ -21,16 +21,14 @@ The first two operations can be implemented by deriving from `webcc::RestListSer
```cpp ```cpp
class BookListService : public webcc::RestListService { class BookListService : public webcc::RestListService {
protected: protected:
// Query books based on some criterias. // Get a list of books based on query parameters.
// GET /books?<query>
void Get(const webcc::UrlQuery& query, void Get(const webcc::UrlQuery& query,
webcc::RestResponse* response) override; webcc::RestResponse* response) final;
// Add a new book. // Create a new book.
// POST /books
// The new book's data is attached as request content in JSON format. // The new book's data is attached as request content in JSON format.
void Post(const std::string& request_content, void Post(const std::string& request_content,
webcc::RestResponse* response) override; webcc::RestResponse* response) final;
}; };
``` ```
@ -42,18 +40,18 @@ The others, derive from `webcc::RestDetailService`:
class BookDetailService : public webcc::RestDetailService { class BookDetailService : public webcc::RestDetailService {
protected: protected:
// Get the detailed information of a book. // Get the detailed information of a book.
void Get(const std::vector<std::string>& url_sub_matches, void Get(const webcc::UrlSubMatches& url_sub_matches,
const webcc::UrlQuery& query, const webcc::UrlQuery& query,
webcc::RestResponse* response) override; webcc::RestResponse* response) final;
// Update the information of a book. // Update a book.
void Put(const std::vector<std::string>& url_sub_matches, void Put(const webcc::UrlSubMatches& url_sub_matches,
const std::string& request_content, const std::string& request_content,
webcc::RestResponse* response) override; webcc::RestResponse* response) final;
// Delete a book. // Delete a book.
void Delete(const std::vector<std::string>& url_sub_matches, void Delete(const webcc::UrlSubMatches& url_sub_matches,
webcc::RestResponse* response) override; webcc::RestResponse* response) final;
}; };
``` ```
@ -62,7 +60,7 @@ As you can see, all you have to do is to override the proper virtual functions w
The detailed implementation is out of the scope of this document, but here is an example: The detailed implementation is out of the scope of this document, but here is an example:
```cpp ```cpp
void BookDetailService::Get(const std::vector<std::string>& url_sub_matches, void BookDetailService::Get(const webcc::UrlSubMatches& url_sub_matches,
const webcc::UrlQuery& query, const webcc::UrlQuery& query,
webcc::RestResponse* response) { webcc::RestResponse* response) {
if (url_sub_matches.size() != 1) { if (url_sub_matches.size() != 1) {

@ -16,7 +16,6 @@ class BookListService : public webcc::RestListService {
protected: protected:
// Get a list of books based on query parameters. // Get a list of books based on query parameters.
// Support query parameters.
void Get(const webcc::UrlQuery& query, webcc::RestResponse* response) final; void Get(const webcc::UrlQuery& query, webcc::RestResponse* response) final;
// Create a new book. // Create a new book.

Loading…
Cancel
Save