Skip to content

Commit

Permalink
Fix indentation & numbering in middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
bryceschober authored Mar 30, 2022
1 parent 1e73642 commit 0440521
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 0440521

Please sign in to comment.