Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 39 lines (36 sloc) 1.05 KB
<?php
use Psr\Http\{
Message\ResponseInterface,
Message\ServerRequestInterface as Request,
Server\MiddlewareInterface,
Server\RequestHandlerInterface as RequestHandler
};
use App\{
ContainerAwareTrait,
ContainerAwareInterface
};
use App\Middleware\Error;
class SendResponse implements MiddlewareInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* Process request
*
* @param ServerRequestInterface $request request
* @param RequestHandlerInterface $handler
*
* @return object ResponseInterface
*/
public function process(Request $request, RequestHandler $handler) : ResponseInterface
{
$router = $this->getContainer()->get('router');
$response = null;
if ($router->hasMatch()) { // Dispatch application
// $response = call_user_func_array(array($class, $method),$parameters);
}
if ($response instanceof ResponseInterface) {
return $response;
}
return $handler->process(new Error('404'));
}
}