mirror of
https://github.com/oatpp/oatpp.git
synced 2025-04-06 18:40:24 +08:00
Update 1.3.0.md
This commit is contained in:
parent
1521d335b3
commit
398abeb825
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user