Skip to content

Commit

Permalink
Merge pull request #378 from bryceschober/patch-1
Browse files Browse the repository at this point in the history
Fix indentation & numbering in middleware
  • Loading branch information
The-EDev authored Apr 1, 2022
2 parents 1e73642 + 0440521 commit 1002ded
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions docs/guides/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,39 @@ 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
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

Expand Down Expand Up @@ -91,4 +93,4 @@ struct AdminAreaGuard : crow::ILocalMiddleware
void after_handle(crow::request& req, crow::response& res, context& ctx)
{}
};
```
```

0 comments on commit 1002ded

Please sign in to comment.