/** * {@inheritdoc} */ public function execute(Request $request) { $start = microtime(true); $httpRequest = new HTTP\Request(); $body = new Body(); $httpResponse = new HTTP\Response(); $httpResponse->setBody($body); try { $result = $this->runCallback($httpRequest, $httpResponse); $body->append($result); } catch (\Exception $e) { $httpResponse->setResponseCode(500); //TODO: Maybe implement something more complex, with better error reporting? Error::printException($e, false); $body->append(sprintf('Error: %s', $e->getMessage())); } $this->prepareResponse($httpResponse); return $httpResponse->toArray(); }