/** * {@inheritdoc} */ public function dispatch(\Jivoo\Http\ActionRequest $request, \Psr\Http\Message\ResponseInterface $response) { $file = $this->scheme->find(implode('/', $this->parameters)); if (!isset($file)) { return $this->scheme->handleError($request, $response); } $type = $this->scheme->getMimeType($file); $response = \Jivoo\Http\Message\Response::file($file, $type)->cached(); return $response; }
/** * {@inheritdoc} */ public function dispatch(\Jivoo\Http\ActionRequest $request, \Psr\Http\Message\ResponseInterface $response) { return \Jivoo\Http\Message\Response::redirect($this->getUrl()); }
/** * Create a path redirect. * * @param string|string[] $path Path array. * @param array $query Query. * @param string $fragment Fragment. * @param bool $permanent Whether redirect is permanent. * @param bool $rewrite Whether to force removal of script name from path. * @return ResponseInterface A redirect response. */ public function redirectPath($path, array $query = [], $fragment = '', $permanent = false, $rewrite = false) { $location = new Message\Uri($this->request->pathToString($path, $rewrite)); $location = $location->withQuery(http_build_query($query))->withFragment($fragment); return Message\Response::redirect($location, $permanent); }