public function __invoke(HttpRequest $httpRequest, HttpResponse $httpResponse)
{
$start = microtime(true);
$request = new Http\Request($httpRequest);
$response = new Http\Response($httpResponse, $this->name, $this->version);
try {
$this->router->launch($request, $response, function () use($request, $response, $start) {
$end = microtime(true) - $start;
$response->addHeader("X-Response-Time", $end);
$response->addHeader("Date", date(DATE_RFC822));
$response->addHeader("Access-Control-Request-Method", "POST, GET, PUT, DEL");
$response->addHeader("Access-Control-Allow-Origin", $this->allowOrigin);
$response->end();
});
} catch (\Exception $e) {
$response->write($e->getMessage());
$response->setStatus(500);
$response->end();
}
}