Skip to content

Commit a5e7a9b

Browse files
authored
Updated request attribute injection for Slim v4
The example for "Request attribute injection" was not compatible for Slim v4, I have updated it. This assumes there is a use `Psr\Http\Server\RequestHandlerInterface;`.
1 parent e7a568c commit a5e7a9b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ As you can see above, the route's URL contains a `name` placeholder. By simply a
8787
#### Request attribute injection
8888

8989
```php
90-
$app->add(function ($request, $response, $next) {
90+
$app->add(function (ServerRequestInterface $request, RequestHandlerInterface $handler) {
9191
$request = $request->withAttribute('name', 'Bob');
92-
return $next($request, $response);
92+
$response = $handler->handle($request);
93+
return $response;
9394
});
9495

9596
$app->get('/', function ($name, ResponseInterface $response) {

0 commit comments

Comments
 (0)