mirror of
https://github.com/flarum/framework.git
synced 2025-01-21 20:14:00 +08:00
Http\AbstractServer: Allow usage as PSR-7 middleware
This commit is contained in:
parent
f403feb3b1
commit
181c19eac7
|
@ -15,6 +15,8 @@ use Flarum\Core\EmailToken;
|
|||
use Flarum\Core\PasswordToken;
|
||||
use Flarum\Foundation\AbstractServer as BaseAbstractServer;
|
||||
use Flarum\Foundation\Application;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Zend\Diactoros\Server;
|
||||
use Zend\Stratigility\MiddlewareInterface;
|
||||
|
||||
|
@ -36,6 +38,23 @@ abstract class AbstractServer extends BaseAbstractServer
|
|||
$server->listen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use as PSR-7 middleware
|
||||
*
|
||||
* @param $request
|
||||
* @param $response
|
||||
* @param null $out
|
||||
* @return mixed
|
||||
*/
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out = null)
|
||||
{
|
||||
$this->collectGarbage($this->app);
|
||||
|
||||
$middleware = $this->getMiddleware($this->app);
|
||||
|
||||
return $middleware($request, $response, $out);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @return MiddlewareInterface
|
||||
|
|
Loading…
Reference in New Issue
Block a user