mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Merge pull request #378 from bryceschober/patch-1
Fix indentation & numbering in middleware
This commit is contained in:
commit
1002ded116
@ -11,18 +11,19 @@ There are two possible signatures for before_handle
|
||||
|
||||
1. if you only need to access this middleware's context.
|
||||
|
||||
```cpp
|
||||
void before_handle(request& req, response& res, context& ctx)
|
||||
```
|
||||
```cpp
|
||||
void before_handle(request& req, response& res, context& ctx)
|
||||
```
|
||||
|
||||
2. To get access to other middlewares context
|
||||
``` cpp
|
||||
template <typename AllContext>
|
||||
void before_handle(request& req, response& res, context& ctx, AllContext& all_ctx)
|
||||
{
|
||||
auto other_ctx = all_ctx.template get<OtherMiddleware>();
|
||||
}
|
||||
```
|
||||
|
||||
``` cpp
|
||||
template <typename AllContext>
|
||||
void before_handle(request& req, response& res, context& ctx, AllContext& all_ctx)
|
||||
{
|
||||
auto other_ctx = all_ctx.template get<OtherMiddleware>();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## after_handle
|
||||
@ -30,18 +31,19 @@ There are two possible signatures for after_handle
|
||||
|
||||
1. if you only need to access this middleware's context.
|
||||
|
||||
```cpp
|
||||
void after_handle(request& req, response& res, context& ctx)
|
||||
```
|
||||
```cpp
|
||||
void after_handle(request& req, response& res, context& ctx)
|
||||
```
|
||||
|
||||
2. To get access to other middlewares context
|
||||
``` cpp
|
||||
template <typename AllContext>
|
||||
void after_handle(request& req, response& res, context& ctx, AllContext& all_ctx)
|
||||
{
|
||||
auto other_ctx = all_ctx.template get<OtherMiddleware>();
|
||||
}
|
||||
```
|
||||
|
||||
``` cpp
|
||||
template <typename AllContext>
|
||||
void after_handle(request& req, response& res, context& ctx, AllContext& all_ctx)
|
||||
{
|
||||
auto other_ctx = all_ctx.template get<OtherMiddleware>();
|
||||
}
|
||||
```
|
||||
|
||||
## Using middleware
|
||||
|
||||
@ -91,4 +93,4 @@ struct AdminAreaGuard : crow::ILocalMiddleware
|
||||
void after_handle(crow::request& req, crow::response& res, context& ctx)
|
||||
{}
|
||||
};
|
||||
```
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user