dispatcher->dispatch( $request->getMethod(), $request->getUri()->getPath(), ); if ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) { throw new MethodNotAllowed; } if ($routeInfo[0] === Dispatcher::FOUND) { foreach ($routeInfo[2] as $attributeName => $attributeValue) { $request = $request->withAttribute($attributeName, $attributeValue); } return $request->withAttribute( $this->routeAttributeName, $routeInfo[1] ); } throw new NotFound; } public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { try { $request = $this->decorateRequest($request); } catch (NotFound) { $response = $this->responseFactory->createResponse(404); $response->getBody()->write('Not Found'); return $response; } catch (MethodNotAllowed) { return $this->responseFactory->createResponse(405); } catch (Throwable $t) { throw new InternalServerError($t->getMessage(), $t->getCode(), $t); } if ($handler instanceof RoutedRequestHandler) { $handler->setRouteAttributeName($this->routeAttributeName); } return $handler->handle($request); } }