コード例 #1
0
 /**
  * Returns a middleware stack that will be processed by the router middleware.
  * @param Container $container The container used to create the stack
  * @param Route $route The route that was mapped to the request
  * @return MiddlewareStack Middleware stack to call to process the route
  */
 private function getRouteHandlerStack(Container $container, Route $route) : MiddlewareStack
 {
     $stack = new MiddlewareStack();
     $stack->push($this->resolveCallable($container, $route->getHandler()));
     return $stack;
 }
コード例 #2
0
 /**
  * Returns a response used to redirect to the canonical URL of the route.
  * @param Request $request The processed request
  * @param Response $response The processed response
  * @param Route $route The matched route
  * @return Response The response with the redirection header
  */
 private function getRedirectResponse(Request $request, Response $response, Route $route) : Response
 {
     $path = $this->withBasePath($route->getCanonicalPath());
     $uri = $request->getUri()->withPath($path);
     return $response->withStatus(302)->withHeader('Location', (string) $uri);
 }