Skip to content

Commit 42a42ec

Browse files
committed
oak: Replace cppnetlib with oatpp
1 parent 89dc944 commit 42a42ec

File tree

8 files changed

+142
-261
lines changed

8 files changed

+142
-261
lines changed

NOTICE.md

+7
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,12 @@ installed with the help of Conan):
110110
- Website: https://cpp-netlib.org
111111
- Conan-Package: cpp-netlib
112112

113+
- Oat++
114+
- License: Apache-2.0
115+
- License-Source: https://github.com/oatpp/oatpp/blob/master/LICENSE
116+
- Website: https://oatpp.io/
117+
- Source: https://github.com/oatpp/oatpp
118+
- Conan-Package: oatpp
119+
113120
Additional third-party content that is used for the web user-interface
114121
is listed in the `ui/LICENSE-3RD-PARTY.txt` file.

docs/usage/package-hierarchy.excalidraw

+1-1
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@
643643
"versionNonce": 1492357253,
644644
"isDeleted": false,
645645
"boundElementIds": null,
646-
"text": "libcppnetlib",
646+
"text": "oatpp",
647647
"fontSize": 20,
648648
"fontFamily": 1,
649649
"textAlign": "center",

docs/usage/package-hierarchy.svg

+1-1
Loading

docs/usage/understanding-cloe-packages.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Each of the boxes in the image above represents a single Conan package. The
2727
set of packages is not exhaustive, as implied by the boxes with ellipsis.
2828
The arrows define dependencies between packages. For example, ``cloe-engine``
2929
depends on ``cloe-runtime``. Most plugins depend on ``cloe-models``, which
30-
in turn depends on ``cloe-runtime``. Some packages, like ``libcppnetlib`` are
30+
in turn depends on ``cloe-runtime``. Some packages, like ``oatpp`` are
3131
not developed by us, but packaged into Conan packages by us. Other dependencies
3232
(not shown) such as Boost, are retrieved from the Conan Center, which contains
3333
a large collection of Open Source libraries and tools.

oak/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(target cloe-oak)
1010
set(alias cloe::oak)
1111

1212
find_package(cloe-runtime REQUIRED)
13-
find_package(cppnetlib REQUIRED)
13+
find_package(oatpp REQUIRED)
1414
find_package(Boost COMPONENTS headers REQUIRED)
1515

1616
file(GLOB ${target}_PUBLIC_HEADERS "include/**/*.hpp")
@@ -27,7 +27,7 @@ add_library(${target}
2727
add_library(${alias} ALIAS ${target})
2828
set_target_linting(${target})
2929
set_target_properties(${target} PROPERTIES
30-
CXX_STANDARD 14
30+
CXX_STANDARD 17
3131
CXX_STANDARD_REQUIRED ON
3232
)
3333
target_include_directories(${target}
@@ -40,7 +40,7 @@ target_include_directories(${target}
4040
target_link_libraries(${target}
4141
PUBLIC
4242
cloe::runtime
43-
cppnetlib::cppnetlib
43+
oatpp::oatpp
4444
Boost::headers
4545
)
4646

@@ -56,7 +56,7 @@ if(BUILD_TESTING)
5656
src/oak/server_test.cpp
5757
)
5858
set_target_properties(test-oak PROPERTIES
59-
CXX_STANDARD 14
59+
CXX_STANDARD 17
6060
CXX_STANDARD_REQUIRED ON
6161
)
6262
target_include_directories(test-oak

oak/conanfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def set_version(self):
4242

4343
def requirements(self):
4444
self.requires(f"cloe-runtime/{self.version}@cloe/develop")
45-
self.requires("cpp-netlib/0.13.0@cloe/stable")
45+
self.requires("oatpp/1.3.0")
4646

4747
def build_requirements(self):
4848
self.test_requires("gtest/[~1.10]")

oak/include/oak/server.hpp

+4-54
Original file line numberDiff line numberDiff line change
@@ -26,61 +26,13 @@
2626
#include <string> // for string
2727
#include <vector> // for vector<>
2828

29-
// Requires: cppnetlib
30-
#include <boost/network/include/http/server.hpp>
31-
#include <boost/network/utils/thread_pool.hpp>
29+
#include <oatpp/network/Server.hpp>
3230

3331
#include "oak/registrar.hpp" // for StaticRegistrar, BufferRegistrar
34-
#include "oak/route_muxer.hpp" // for Muxer<>
3532

3633
namespace oak {
3734

38-
// These forward-declarations are a necessary evil:
39-
class ServerImplHandler;
40-
using ServerImpl = boost::network::http::server<ServerImplHandler>;
41-
42-
/**
43-
* ServerImplHandler is the main request handler for the server.
44-
*
45-
* It implements an interface defined by boost::network::http::server.
46-
*/
47-
class ServerImplHandler {
48-
public:
49-
ServerImplHandler();
50-
51-
/**
52-
* Handle every request from the server.
53-
*
54-
* Every single request that passes through the server has to go through this
55-
* handler. If the muxer has an endpoint that matches the request, then it
56-
* gets passed through. The muxer has a default endpoint, so the nominal case
57-
* is that every request is passed to some handler from the muxer.
58-
*/
59-
void operator()(ServerImpl::request const&, ServerImpl::connection_ptr);
60-
61-
/**
62-
* Log an error from the server.
63-
*/
64-
void log(const ServerImpl::string_type& msg);
65-
66-
/**
67-
* Add a handler for a specific endpoint.
68-
*/
69-
void add(const std::string& key, Handler h);
70-
71-
/**
72-
* Return a list of all registered endpoints.
73-
*/
74-
std::vector<std::string> endpoints() const { return muxer.routes(); }
75-
76-
/**
77-
* Return endpoint data in json format.
78-
*/
79-
cloe::Json endpoints_to_json(const std::vector<std::string>& endpoints) const;
80-
81-
private:
82-
Muxer<Handler> muxer;
83-
};
35+
class GreedyHandler;
8436

8537
/**
8638
* A Server accepts and serves endpoints for Handlers.
@@ -169,10 +121,8 @@ class Server {
169121

170122
// State
171123
bool listening_;
172-
ServerImplHandler handler_;
173-
std::unique_ptr<ServerImpl::options> options_;
174-
std::unique_ptr<ServerImpl> server_;
175-
std::unique_ptr<boost::thread> thread_;
124+
std::shared_ptr<oatpp::network::Server> server_;
125+
std::shared_ptr<GreedyHandler> handler_;
176126
};
177127

178128
} // namespace oak

0 commit comments

Comments
 (0)