/** * Handles a raw request * * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handleRequest(ServerRequestInterface $request) { try { return $this->getRequestHandlerImplementation()->handleRequest($request); } catch (NotFoundException $exception) { $response = new Response(); return $response->withStatus(404); } catch (NotAllowedException $exception) { $response = new Response(); return $response->withStatus(405); } catch (Exception $exception) { $response = new Response(); return $response->withStatus(500); } }
/** * @test */ public function testCanSetCustomReasonPhrase() { $response = $this->response->withStatus(422, 'Foo Bar!'); $this->assertEquals('Foo Bar!', $response->getReasonPhrase()); }
/** * @param string $what * @param string $should * @param string $i * @param string $do * * @return Response * @info This Action will be called for defined route: GET /api/{what}/{should}/{i}/{do} * @info Example URI: GET http://localhost:8000/api/doo/whatever/you/want */ public function fooAction($what, $should, $i, $do) { $response = new Response(); $response->getBody()->write(addslashes($what) . ' ' . addslashes($should) . ' ' . addslashes($i) . ' ' . addslashes($do) . '!'); return $response->withStatus(200, 'Thank you'); }