Skip to content

Commit 355c393

Browse files
committed
Improve middleware doc
1 parent cf80cfc commit 355c393

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

guide/en/structure/middleware.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
Yii works with HTTP using the abstraction layer built around [PSR-7 HTTP message interfaces](https://www.php-fig.org/psr/psr-7/)
44
and [PSR-15 request handler/middleware interfaces](https://www.php-fig.org/psr/psr-15/).
55

6-
The application is composed of one or several middleware. When the URL is requested, the request object is passed to
7-
the middleware dispatcher that starts executing middleware. Each middleware, given the request, can:
6+
The application is composed of one or several middleware. Middleware runs between request and response.
7+
When the URL is requested, the request object is passed to the middleware dispatcher that starts executing middleware one after another.
8+
Each middleware, given the request, can:
89

9-
- Pass request to the next middleware or return a response.
10-
- Perform some work before and after the next middleware.
10+
- Pass the request to the next middleware performing some work before / after it.
11+
- Form the response and return it.
1112

1213
Depending on middleware used, application behavior may vary significantly.
1314

@@ -112,7 +113,7 @@ To create middleware, you need to implement a single `process` method of `Psr\Ht
112113
public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface;
113114
```
114115

115-
There are many ways to handle request and choosing one depends on what the middleware should achieve.
116+
There are multiple ways to handle request and choosing one depends on what the middleware should achieve.
116117

117118
### Forming response directly
118119

0 commit comments

Comments
 (0)