Update quick example in README.
This commit is contained in:
@@ -41,10 +41,11 @@ class BookDetailService : public webcc::RestDetailService {
|
|||||||
protected:
|
protected:
|
||||||
// Get the detailed information of a book.
|
// Get the detailed information of a book.
|
||||||
bool Get(const std::vector<std::string>& url_sub_matches,
|
bool Get(const std::vector<std::string>& url_sub_matches,
|
||||||
|
const webcc::UrlQuery& query,
|
||||||
std::string* response_content) final;
|
std::string* response_content) final;
|
||||||
|
|
||||||
// Update the information of a book.
|
// Update the information of a book.
|
||||||
bool Patch(const std::vector<std::string>& url_sub_matches,
|
bool Put(const std::vector<std::string>& url_sub_matches,
|
||||||
const std::string& request_content,
|
const std::string& request_content,
|
||||||
std::string* response_content) final;
|
std::string* response_content) final;
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ The detailed implementation is out of the scope of this document, but here is an
|
|||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
bool BookDetailService::Get(const std::vector<std::string>& url_sub_matches,
|
bool BookDetailService::Get(const std::vector<std::string>& url_sub_matches,
|
||||||
|
const webcc::UrlQuery& query,
|
||||||
std::string* response_content) {
|
std::string* response_content) {
|
||||||
if (url_sub_matches.size() != 1) {
|
if (url_sub_matches.size() != 1) {
|
||||||
return false;
|
return false;
|
||||||
@@ -76,11 +78,8 @@ Last step, register the services and run the server:
|
|||||||
```cpp
|
```cpp
|
||||||
webcc::RestServer server(8080, 2);
|
webcc::RestServer server(8080, 2);
|
||||||
|
|
||||||
server.RegisterService(std::make_shared<BookListService>(),
|
server.Bind(std::make_shared<BookListService>(), "/books", false);
|
||||||
"/books");
|
server.Bind(std::make_shared<BookDetailService>(), "/book/(\\d+)", true);
|
||||||
|
|
||||||
server.RegisterService(std::make_shared<BookDetailService>(),
|
|
||||||
"/book/(\\d+)");
|
|
||||||
|
|
||||||
server.Run();
|
server.Run();
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user