コード例 #1
0
 /**
  * Return a exception response.
  *
  * @return \Parest\Rest\Service\Http\Response
  */
 public function response()
 {
     $response = new Response();
     $response->setStatusCode($this->statusCode, $this->statusMessage);
     empty($this->code) and $this->code = $this->statusCode;
     empty($this->message) and $this->message = $this->statusMessage;
     $response->setContent(['code' => $this->code, 'message' => $this->message, 'description' => $this->description]);
     return $response;
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: panlatent/parest
 /**
  * Response Http OPTIONS method. Set the resource response to the client can use Http methods.
  *
  * @param string $childResourceName
  */
 public function options($childResourceName = '')
 {
     $options = [];
     $childResourceName = str_replace('-', '', ucwords($childResourceName));
     foreach (['get', 'post', 'put', 'patch', 'delete', 'head'] as $httpMethod) {
         $methodName = $childResourceName ? $httpMethod . $childResourceName : $httpMethod;
         if (is_callable(array($this, $methodName))) {
             $method = new ReflectionMethod($this, $methodName);
             $method->isPublic() and $options[] = strtoupper($httpMethod);
         }
     }
     $this->response->setContent($options);
 }
コード例 #3
0
ファイル: BaseAuth.php プロジェクト: panlatent/parest
 /**
  * Request the client sends authorization information.
  *
  * Call this method when a restful api client is not authorized.
  *
  * @todo
  * @param \Parest\Rest\Service\Http\Response $response
  * @param array                 $parameters
  */
 public function ask($response, $parameters = [])
 {
     $parameters = array_merge(['realm' => $this->_realm], $parameters);
     $response->setHeaderAppendParameters('WWW-Authenticate', $this->_authorizationType, $parameters);
 }