mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
Update 1.3.0.md
This commit is contained in:
parent
cc40fe69c8
commit
00ee3eea78
@ -9,6 +9,7 @@ Contents:
|
||||
- [The New oatpp::String](#the-new-oatppstring)
|
||||
- [ConnectionPool::get() Timeout](#connectionpoolget-timeout)
|
||||
- [JSON Serializer Escape Flags](#json-serializer-escape-flags)
|
||||
- [ConnectionMonitor](#connectionmonitor)
|
||||
- [Response::getBody()](#responsegetbody)
|
||||
- [data::stream::FIFOStream](#datastreamfifostream)
|
||||
- [data::stream::BufferedInputStream](#datastreambufferedinputstream)
|
||||
@ -127,6 +128,38 @@ Output:
|
||||
res='"https://oatpp.io/"' # solidus isn't escaped
|
||||
```
|
||||
|
||||
## ConnectionMonitor
|
||||
|
||||
`oatpp::network::monitor::ConnectionMonitor` is a middleman who's able to monitor provided connections and close those ones that not satisfy selected rules.
|
||||
|
||||
```cpp
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([] {
|
||||
|
||||
auto connectionProvider = oatpp::network::tcp::server::ConnectionProvider::createShared({"0.0.0.0", 8000, oatpp::network::Address::IP_4});
|
||||
auto monitor = std::make_shared<oatpp::network::monitor::ConnectionMonitor>(connectionProvider);
|
||||
|
||||
/* close all connections that stay opened for more than 120 seconds */
|
||||
monitor->addMetricsChecker(
|
||||
std::make_shared<oatpp::network::monitor::ConnectionMaxAgeChecker>(
|
||||
std::chrono::seconds(120)
|
||||
)
|
||||
);
|
||||
|
||||
/* close all connections that have had no successful reads and writes for longer than 5 seconds */
|
||||
monitor->addMetricsChecker(
|
||||
std::make_shared<oatpp::network::monitor::ConnectionInactivityChecker>(
|
||||
std::chrono::seconds(5),
|
||||
std::chrono::seconds(5),
|
||||
)
|
||||
);
|
||||
|
||||
return monitor;
|
||||
|
||||
}());
|
||||
```
|
||||
|
||||
**Note:** `ConnectionMonitor` also works with `ClientConnectionProvider` as well.
|
||||
|
||||
## Response::getBody()
|
||||
|
||||
`oatpp::web::protocol::http::outgoing::Response` has a new method `getBody()` to retreive the body of the response. This is handy for response interceptors.
|
||||
|
Loading…
Reference in New Issue
Block a user