Rework the server to remove rest_xxx classes.

This commit is contained in:
Chunting Gu
2019-06-21 13:53:00 +08:00
parent 43aadee885
commit 4140b4f94c
24 changed files with 311 additions and 318 deletions
+4 -4
View File
@@ -2,12 +2,11 @@
#include <string>
#include "webcc/logger.h"
#include "webcc/rest_server.h"
#include "webcc/rest_service.h"
#include "webcc/server.h"
// -----------------------------------------------------------------------------
class FileUploadService : public webcc::RestService {
class FileUploadService : public webcc::Service {
public:
void Handle(const webcc::RestRequest& request,
webcc::RestResponse* response) override {
@@ -48,7 +47,8 @@ int main(int argc, char* argv[]) {
std::size_t workers = 2;
try {
webcc::RestServer server(port, workers);
// TODO: doc root
webcc::Server server(port, workers);
server.Bind(std::make_shared<FileUploadService>(), "/upload", false);
+5 -5
View File
@@ -7,8 +7,7 @@
#include "json/json.h"
#include "webcc/logger.h"
#include "webcc/rest_server.h"
#include "webcc/rest_service.h"
#include "webcc/server.h"
#include "examples/common/book.h"
#include "examples/common/book_json.h"
@@ -34,7 +33,7 @@ static void Sleep(int seconds) {
// -----------------------------------------------------------------------------
class BookListService : public webcc::RestListService {
class BookListService : public webcc::ListService {
public:
explicit BookListService(int sleep_seconds)
: sleep_seconds_(sleep_seconds) {
@@ -58,7 +57,7 @@ private:
// The URL is like '/books/{BookID}', and the 'url_matches' parameter
// contains the matched book ID.
class BookDetailService : public webcc::RestDetailService {
class BookDetailService : public webcc::DetailService {
public:
explicit BookDetailService(int sleep_seconds)
: sleep_seconds_(sleep_seconds) {
@@ -227,7 +226,8 @@ int main(int argc, char* argv[]) {
std::size_t workers = 2;
try {
webcc::RestServer server(port, workers);
// TODO: doc root
webcc::Server server(port, workers);
server.Bind(std::make_shared<BookListService>(sleep_seconds),
"/books", false);