You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -48,7 +48,7 @@ $dispatcher = new MiddlewareDispatcher(
48
48
In the above `$diContainer` is an instance of [PSR-11](https://www.php-fig.org/psr/psr-11/)`\Psr\Container\ContainerInterface`
49
49
and `$eventDispatcher` is an instance of [PSR-14](https://www.php-fig.org/psr/psr-14/)`Psr\EventDispatcher\EventDispatcherInterface`.
50
50
51
-
After dispatcher instance obtained, it should be fed with some middleware:
51
+
After dispatcher instance obtained, it should be fed with some middleware:
52
52
53
53
```php
54
54
$dispatcher = $dispatcher->withMiddlewares([
@@ -65,30 +65,33 @@ In the above we have used a callback. Overall the following options are availabl
65
65
`index()` method will be executed.
66
66
- A name of PSR-15 middleware class. The middleware instance will be obtained from container.
67
67
- A name of PSR-15 request handler class. The request handler instance will be obtained from container and executed.
68
-
- A name or instance of invokable class. If the name of invokable class is provided, the instance will be
68
+
- A name or instance of invokable class. If the name of invokable class is provided, the instance will be
69
69
obtained from container and executed.
70
70
- A function returning a middleware such as
71
+
71
72
```php
72
73
static function (): MiddlewareInterface {
73
74
return new TestMiddleware();
74
75
}
75
76
```
77
+
76
78
The middleware returned will be executed.
77
79
- A callback `function(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface`.
78
80
- An array definition (see [syntax](https://github.com/yiisoft/definitions#arraydefinition)) of middleware:
81
+
79
82
```php
80
83
[
81
84
'class' => MyMiddleware::class,
82
85
'__construct()' => [
83
86
'someVar' => 42,
84
87
],
85
88
]
86
-
```
89
+
```
87
90
88
91
For handler action and callable typed parameters are automatically injected using dependency injection container.
89
92
Current request and handler could be obtained by type-hinting for `ServerRequestInterface` and `RequestHandlerInterface`.
90
93
91
-
After middleware set is defined, you can do the dispatching:
94
+
After middleware set is defined, you can do the dispatching:
0 commit comments