diff --git a/CMakeLists.txt b/CMakeLists.txt index 6669227..9e7dd4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ add_library(${project_name}-lib ## link libs -find_package(oatpp 1.0.0 REQUIRED) +find_package(oatpp 1.3.0 REQUIRED) target_link_libraries(${project_name}-lib PUBLIC oatpp::oatpp diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7c2f105..2c1a673 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -4,11 +4,11 @@ # https://aka.ms/yaml jobs: - - job: ubuntu_16_04 - displayName: 'Build - Ubuntu 16.04' + - job: ubuntu_20_04 + displayName: 'Build - Ubuntu 20.04' continueOnError: false pool: - vmImage: 'Ubuntu 16.04' + vmImage: 'ubuntu-20.04' container: image: lganzzzo/ubuntu-cmake:latest workspace: diff --git a/src/App.cpp b/src/App.cpp index 4851d1e..89cdc0f 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -1,15 +1,8 @@ -// -// main.cpp -// web-starter-project -// -// Created by Leonid on 2/12/18. -// Copyright © 2018 oatpp. All rights reserved. -// #include "./controller/MyController.hpp" #include "./AppComponent.hpp" -#include "oatpp/network/server/Server.hpp" +#include "oatpp/network/Server.hpp" #include @@ -24,16 +17,13 @@ void run() { AppComponent components; // Create scope Environment components /* create ApiControllers and add endpoints to router */ - auto router = components.httpRouter.getObject(); - - auto myController = MyController::createShared(); - myController->addEndpointsToRouter(router); - + + router->addController(MyController::createShared()); + /* create server */ - - oatpp::network::server::Server server(components.serverConnectionProvider.getObject(), - components.serverConnectionHandler.getObject()); + oatpp::network::Server server(components.serverConnectionProvider.getObject(), + components.serverConnectionHandler.getObject()); OATPP_LOGD("Server", "Running on port %s...", components.serverConnectionProvider.getObject()->getProperty("port").toString()->c_str()); diff --git a/src/AppComponent.hpp b/src/AppComponent.hpp index d6aa608..1409589 100644 --- a/src/AppComponent.hpp +++ b/src/AppComponent.hpp @@ -1,17 +1,10 @@ -// -// AppComponent.hpp -// oatpp-web-starter -// -// Created by Leonid on 3/2/18. -// Copyright © 2018 lganzzzo. All rights reserved. -// #ifndef AppComponent_hpp #define AppComponent_hpp #include "oatpp/web/server/AsyncHttpConnectionHandler.hpp" #include "oatpp/web/server/HttpRouter.hpp" -#include "oatpp/network/server/SimpleTCPConnectionProvider.hpp" +#include "oatpp/network/tcp/server/ConnectionProvider.hpp" #include "oatpp/parser/json/mapping/ObjectMapper.hpp" @@ -40,7 +33,7 @@ class AppComponent { */ OATPP_CREATE_COMPONENT(std::shared_ptr, serverConnectionProvider)([] { /* non_blocking connections should be used with AsyncHttpConnectionHandler for AsyncIO */ - return oatpp::network::server::SimpleTCPConnectionProvider::createShared(8000); + return oatpp::network::tcp::server::ConnectionProvider::createShared({"0.0.0.0", 8000, oatpp::network::Address::IP_4}); }()); /** @@ -53,7 +46,7 @@ class AppComponent { /** * Create ConnectionHandler component which uses Router component to route requests */ - OATPP_CREATE_COMPONENT(std::shared_ptr, serverConnectionHandler)([] { + OATPP_CREATE_COMPONENT(std::shared_ptr, serverConnectionHandler)([] { OATPP_COMPONENT(std::shared_ptr, router); // get Router component OATPP_COMPONENT(std::shared_ptr, executor); // get Async executor component return oatpp::web::server::AsyncHttpConnectionHandler::createShared(router, executor); diff --git a/src/controller/MyController.cpp b/src/controller/MyController.cpp index d2c347c..f8cfded 100644 --- a/src/controller/MyController.cpp +++ b/src/controller/MyController.cpp @@ -1,6 +1,3 @@ -// -// Created by Leonid on 2019-05-27. -// #include "MyController.hpp" diff --git a/src/controller/MyController.hpp b/src/controller/MyController.hpp index f175f66..458e93c 100644 --- a/src/controller/MyController.hpp +++ b/src/controller/MyController.hpp @@ -1,10 +1,3 @@ -// -// MyController.hpp -// web-starter-project -// -// Created by Leonid on 2/12/18. -// Copyright © 2018 oatpp. All rights reserved. -// #ifndef MyController_hpp #define MyController_hpp @@ -15,6 +8,8 @@ #include "oatpp/core/macro/codegen.hpp" #include "oatpp/core/macro/component.hpp" +#include OATPP_CODEGEN_BEGIN(ApiController) //<-- Begin codegen + /** * EXAMPLE ApiController * Basic examples of howto create ENDPOINTs @@ -36,11 +31,6 @@ class MyController : public oatpp::web::server::api::ApiController { return std::shared_ptr(new MyController(objectMapper)); } - /** - * Begin ENDPOINTs generation ('ApiController' codegen) - */ -#include OATPP_CODEGEN_BEGIN(ApiController) - /** * Hello World endpoint Coroutine mapped to the "/" (root) */ @@ -92,20 +82,17 @@ class MyController : public oatpp::web::server::api::ApiController { ENDPOINT_ASYNC_INIT(EchoDtoBody) Action act() override { - return request->readBodyToDtoAsync(controller->getDefaultObjectMapper()).callbackTo(&EchoDtoBody::returnResponse); + return request->readBodyToDtoAsync>(controller->getDefaultObjectMapper()).callbackTo(&EchoDtoBody::returnResponse); } - Action returnResponse(const MessageDto::ObjectWrapper& body){ + Action returnResponse(const oatpp::Object& body){ return _return(controller->createDtoResponse(Status::CODE_200, body)); } }; - /** - * Finish ENDPOINTs generation ('ApiController' codegen) - */ -#include OATPP_CODEGEN_END(ApiController) - }; +#include OATPP_CODEGEN_BEGIN(ApiController) //<-- End codegen + #endif /* MyController_hpp */ diff --git a/src/dto/MyDTOs.hpp b/src/dto/MyDTOs.hpp index 7cbfae9..39700b0 100644 --- a/src/dto/MyDTOs.hpp +++ b/src/dto/MyDTOs.hpp @@ -1,10 +1,3 @@ -// -// UserDto.hpp -// crud -// -// Created by Leonid on 3/13/18. -// Copyright © 2018 oatpp. All rights reserved. -// #ifndef MyDTOs_hpp #define MyDTOs_hpp @@ -18,9 +11,9 @@ * Data Transfer Object. Object containing fields only. * Used in API for serialization/deserialization and validation */ -class HelloDto : public oatpp::data::mapping::type::Object { +class HelloDto : public oatpp::DTO { - DTO_INIT(HelloDto, Object) + DTO_INIT(HelloDto, DTO) DTO_FIELD(String, userAgent, "user-agent"); DTO_FIELD(String, message); @@ -28,9 +21,9 @@ class HelloDto : public oatpp::data::mapping::type::Object { }; -class MessageDto : public oatpp::data::mapping::type::Object { +class MessageDto : public oatpp::DTO { - DTO_INIT(MessageDto, Object) + DTO_INIT(MessageDto, DTO) DTO_FIELD(String, message); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy