public function setResult(RestApi_Result $result)
 {
     foreach ($result->getHeaders() as $name => $value) {
         $this->response->headers()->set($name, $value);
     }
     $this->response->setStatus($result->getCode());
     $this->response->setBody($result->getBody());
 }
 public function asResult()
 {
     $result = new RestApi_Result();
     $result->setCode($this->getCode());
     $result->setBody($this->getMessage());
     $result->setHeaders($this->headers);
     return $result;
 }
 /**
  * @param mixed $body
  * @param int $code
  * @param string[] $headers
  * @return RestApi_Result
  */
 protected function innerResult($body, $code, $headers)
 {
     $result = new RestApi_Result();
     $result->setCode($code);
     $result->setBody(json_encode($body));
     $this->initHeaders($headers);
     $result->setHeaders($headers);
     return $result;
 }