private static function hasAttribute(ServerRequestInterface $request, $name)
    {
        $attributes = $request->getAttribute(Middleware::KEY);

        if (empty($attributes)) {
            return false;
        }

        return array_key_exists($name, $attributes);
    }