Update 1.3.0.md

This commit is contained in:
Leonid Stryzhevskyi 2021-10-15 01:50:18 +03:00 committed by GitHub
parent 1521d335b3
commit 398abeb825
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ Contents:
- [ConnectionPool::get() Timeout](#connectionpoolget-timeout)
- [JSON Serializer Escape Flags](#json-serializer-escape-flags)
- [ConnectionMonitor](#connectionmonitor)
- [Request Data Bundle](#request-data-bundle)
- [Response::getBody()](#responsegetbody)
- [data::stream::FIFOStream](#datastreamfifostream)
- [data::stream::BufferedInputStream](#datastreambufferedinputstream)
@ -160,6 +161,42 @@ OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>
**Note:** `ConnectionMonitor` also works with `ClientConnectionProvider` as well.
## Request Data Bundle
Now there is a data bundle associated with the Request and the Response which makes it easy to pass data through middleware interceptors and endpoints.
Example:
```cpp
class MyAuthInterceptor : public oatpp::web::server::interceptor::RequestInterceptor {
public:
std::shared_ptr<OutgoingResponse> intercept(const std::shared_ptr<IncomingRequest>& request) override {
/* authorize request and get auth data */
oatpp::Object<AuthDto> authData = authorize(request);
if(!authData) {
return OutgoingResponse::createShared(Status::CODE_401, nullptr);
}
/* put auth data to bundle for later use at an endpoint */
request->putBundleData("auth", authData);
return nullptr; // continue processing
}
};
...
ENDPOINT("GET", "videos/{videoId}", getVideoById,
PATH(String, videoId),
BUNDLE(oatpp::Object<AuthDto>, authData, "auth"))
{
...
}
```
## 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.