-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when I add PSR-15 middleware with class string #61
Comments
I think |
With this format of array, is giving me this error:
Code: // Middleware
use Psr\Http\Server\MiddlewareInterface as Middleware;
use Psr\Http\Message\ServerRequestInterface as ServerRequest;
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
use Psr\Http\Message\ResponseInterface as Response;
class ExampleMiddleware implements Middleware
{
public function __construct(Foo $foo)
{
$this->foo = $foo;
}
public function process(ServerRequest $request, RequestHandler $handler): Response
{
$response = $handler->handle($request);
$response->getBody()->write($this->foo->hello());
return $response;
}
}
// config/middleware.php
$app->add([ExampleMiddleware::class, 'process']); |
you should pass MIddlewareInterface instance eg.
or
|
With I think it would be nice to also support this method for adding Slim middleware: $app->add(ExampleMiddleware::class); I think I can try to add this method and send a PR. Thanks :) |
Duplicates #51, trying to get that and related stuff work. :) |
When I add PSR-15 middleware on Slim (with Bridge) with class string, the following error appears:
Code:
But when I add middleware as invokable class the middleware works:
The text was updated successfully, but these errors were encountered: