Defines the following responses capabilities: - Write to the content - End the response (mark it complete) - Determine if the response is complete
Deprecation: since 1.3.0; to be removed with 2.0.0. Do not use the methods defined in this interface; use only those defined in PSR-7.
コード例 #1
0
 /**
  * Return response with JSON header and status.
  *
  * @param PsrResponseInterface|ResponseInterface $response
  * @param int $status
  * @return mixed
  */
 public function response($response, $status = 200)
 {
     return $response->withStatus($status)->withHeader('Content-Type', 'application/json;charset=utf-8');
 }
コード例 #2
0
 /**
  * Ping action.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return string
  */
 public function ping(ServerRequestInterface $request, ResponseInterface $response)
 {
     $data = ['ack' => time(), 'target' => __METHOD__];
     $response->write($this->json->render($data));
     return $this->json->response($response);
 }
コード例 #3
0
 /**
  * Show user.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return \Psr\Http\Message\MessageInterface
  */
 public function user(ServerRequestInterface $request, ResponseInterface $response)
 {
     $response->write($this->json->render($this->user->toArray()));
     return $this->json->response($response);
 }
コード例 #4
0
 /**
  * Index action.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return int
  */
 public function home(ServerRequestInterface $request, ResponseInterface $response)
 {
     $data = ['routerName' => 'FastRoute', 'routerDocs' => 'https://github.com/nikic/FastRoute', 'templateName' => 'Twig', 'templateDocs' => 'http://twig.sensiolabs.org/documentation'];
     $response->write($this->template->render('app::index', $data));
     return $response;
 }