protected function getSession(ServerRequestInterface $request): SessionInterface
    {
        if ($this->session === null) {
            $this->session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE);

            if (!$this->session instanceof SessionInterface) {
                throw MissingSessionContainerException::create();
            }
        }

        return $this->session;
    }