Merge pull request #378 from bryceschober/patch-1

Fix indentation & numbering in middleware
This commit is contained in:
Farook Al-Sammarraie 2022-04-01 04:04:39 +03:00 committed by GitHub
commit 1002ded116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
{}
};
```
```