public function getRouteForRequest(Request $request)
	{
		$method = $request->getMethod();
		$path = $request->getPathInfo() ?: '/';

		$result = $this->getDispatcher()
			->dispatch($method, $path);

		if ($result[0] == \FastRoute\Dispatcher::NOT_FOUND) {
			throw new NotFoundHttpException("No route match for path $path");
		} else if ($result[0] == \FastRoute\Dispatcher::METHOD_NOT_ALLOWED) {
			throw new MethodNotAllowedHttpException($result[1],
				"Method $method not allowed for path $path");
		} else if ($result[0] !== \FastRoute\Dispatcher::FOUND) {
			throw new \RuntimeException('Unknown result from FastRoute: '.$result[0]);
		}

		return $this->matchRoute($result[1], $result[2], $request);
	}