From 5bd9c91a5522879c9fa3724210a23ea659bfb4a6 Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Sun, 17 May 2020 01:00:54 +0300 Subject: [PATCH 1/6] Update to the latest oatpp API. --- CMakeLists.txt | 2 +- src/App.cpp | 7 ------- src/AppComponent.hpp | 7 ------- src/controller/MyController.cpp | 3 --- src/controller/MyController.hpp | 21 ++++----------------- src/dto/MyDTOs.hpp | 11 ++--------- 6 files changed, 7 insertions(+), 44 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6669227..84c423b 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.1.0 REQUIRED) target_link_libraries(${project_name}-lib PUBLIC oatpp::oatpp diff --git a/src/App.cpp b/src/App.cpp index 4851d1e..5032b26 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -1,10 +1,3 @@ -// -// 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" diff --git a/src/AppComponent.hpp b/src/AppComponent.hpp index d6aa608..f220e94 100644 --- a/src/AppComponent.hpp +++ b/src/AppComponent.hpp @@ -1,10 +1,3 @@ -// -// AppComponent.hpp -// oatpp-web-starter -// -// Created by Leonid on 3/2/18. -// Copyright © 2018 lganzzzo. All rights reserved. -// #ifndef AppComponent_hpp #define AppComponent_hpp 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..4b4c1a6 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) */ @@ -101,11 +91,8 @@ class MyController : public oatpp::web::server::api::ApiController { }; - /** - * 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..d50c432 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,7 +11,7 @@ * 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::Object { DTO_INIT(HelloDto, Object) @@ -28,7 +21,7 @@ class HelloDto : public oatpp::data::mapping::type::Object { }; -class MessageDto : public oatpp::data::mapping::type::Object { +class MessageDto : public oatpp::Object { DTO_INIT(MessageDto, Object) From f9d62c7c5d434b87900a7242d2c3375b75f18c6b Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Sat, 23 May 2020 23:50:16 +0300 Subject: [PATCH 2/6] Update to the latest oatpp API. --- src/controller/MyController.hpp | 4 ++-- src/dto/MyDTOs.hpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controller/MyController.hpp b/src/controller/MyController.hpp index 4b4c1a6..458e93c 100644 --- a/src/controller/MyController.hpp +++ b/src/controller/MyController.hpp @@ -82,10 +82,10 @@ 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)); } diff --git a/src/dto/MyDTOs.hpp b/src/dto/MyDTOs.hpp index d50c432..39700b0 100644 --- a/src/dto/MyDTOs.hpp +++ b/src/dto/MyDTOs.hpp @@ -11,9 +11,9 @@ * Data Transfer Object. Object containing fields only. * Used in API for serialization/deserialization and validation */ -class HelloDto : public oatpp::Object { +class HelloDto : public oatpp::DTO { - DTO_INIT(HelloDto, Object) + DTO_INIT(HelloDto, DTO) DTO_FIELD(String, userAgent, "user-agent"); DTO_FIELD(String, message); @@ -21,9 +21,9 @@ class HelloDto : public oatpp::Object { }; -class MessageDto : public oatpp::Object { +class MessageDto : public oatpp::DTO { - DTO_INIT(MessageDto, Object) + DTO_INIT(MessageDto, DTO) DTO_FIELD(String, message); From 401b53bd2055b7de12958c1ff3391a264b65b27e Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Wed, 30 Sep 2020 04:32:21 +0300 Subject: [PATCH 3/6] Update to the latest oatpp API. --- CMakeLists.txt | 2 +- src/App.cpp | 6 +++--- src/AppComponent.hpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84c423b..f80db48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ add_library(${project_name}-lib ## link libs -find_package(oatpp 1.1.0 REQUIRED) +find_package(oatpp 1.2.0 REQUIRED) target_link_libraries(${project_name}-lib PUBLIC oatpp::oatpp diff --git a/src/App.cpp b/src/App.cpp index 5032b26..e316ff4 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -2,7 +2,7 @@ #include "./controller/MyController.hpp" #include "./AppComponent.hpp" -#include "oatpp/network/server/Server.hpp" +#include "oatpp/network/Server.hpp" #include @@ -25,8 +25,8 @@ void run() { /* 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 f220e94..15cf916 100644 --- a/src/AppComponent.hpp +++ b/src/AppComponent.hpp @@ -4,7 +4,7 @@ #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" @@ -33,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({"localhost", 8000}); }()); /** @@ -46,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); From 9f9d71f422c412f88ceb6bcbd5d658a850ccc1ab Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Sat, 24 Oct 2020 02:04:14 +0300 Subject: [PATCH 4/6] Update connection provider to use IPv4 --- src/AppComponent.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppComponent.hpp b/src/AppComponent.hpp index 15cf916..1409589 100644 --- a/src/AppComponent.hpp +++ b/src/AppComponent.hpp @@ -33,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::tcp::server::ConnectionProvider::createShared({"localhost", 8000}); + return oatpp::network::tcp::server::ConnectionProvider::createShared({"0.0.0.0", 8000, oatpp::network::Address::IP_4}); }()); /** From 9a5465657a74c4c6be86b47de9954053c29ff7ed Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Thu, 24 Dec 2020 01:49:57 +0200 Subject: [PATCH 5/6] Update to the latest oatpp version. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f80db48..17f1eea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ add_library(${project_name}-lib ## link libs -find_package(oatpp 1.2.0 REQUIRED) +find_package(oatpp 1.2.5 REQUIRED) target_link_libraries(${project_name}-lib PUBLIC oatpp::oatpp From b972426c186bb7366b009c2e996f73229d2b94db Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Mon, 25 Oct 2021 23:13:33 +0300 Subject: [PATCH 6/6] update to the latest oatpp API version. --- CMakeLists.txt | 2 +- azure-pipelines.yml | 6 +++--- src/App.cpp | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 17f1eea..9e7dd4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ add_library(${project_name}-lib ## link libs -find_package(oatpp 1.2.5 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 e316ff4..89cdc0f 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -17,14 +17,11 @@ 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(components.serverConnectionProvider.getObject(), components.serverConnectionHandler.getObject()); 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