public function generateResponse($request = null, $currentUrlFragment = false)
    {
        if ($currentUrlFragment === false) {
            $currentUrlFragment = $request->urlPath;
        }

        if (!$this->matchesRequest($request, $currentUrlFragment)) {
            return false;
        }

        UrlHandler::setExecutingUrlHandler($this);

        Log::debug(function () {
            return "Handler " . get_class($this) . " selected to generate response";
        }, "ROUTER");

        Log::indent();

        $context = new PhpContext();
        $context->UrlHandler = $this;

        $this->matchingUrl = $this->getMatchingUrlFragment($request, $currentUrlFragment);

        if ($this->parentHandler) {
            $this->handledUrl = $this->parentHandler->handledUrl . $this->matchingUrl;
        } else {
            $this->handledUrl = $this->matchingUrl;
        }

        $childUrlFragment = substr($currentUrlFragment, strlen($this->matchingUrl));

        foreach ($this->childUrlHandlers as $childHandler) {
            $response = $childHandler->generateResponse($request, $childUrlFragment);

            if ($response !== false) {
                return $response;
            }
        }

        $response = $this->generateResponseForRequest($request, $currentUrlFragment);

        Log::debug(function () use ($response) {
            if ($response !== false) {
                return "Response generated by handler";
            }

            return "Handler deferred generation";
        }, "ROUTER");

        Log::outdent();

        return $response;
    }