小编tva*_*her的帖子

在 Google Cloud Platform 上的 URL 中隐藏“/index.html”

我正在使用存储桶在谷歌云平台上托管一个静态网站,并将主页后缀设置为“index.html”,如谷歌教程中所示,但是,我仍然从 ./dir/index.html 跳转到 ./dir/index.html 。 /目录。

当请求 ./dir/ 时,它会在不更改 URL 的情况下返回“index.html”,这正是我想要的,但如果用户请求时没有尾随正斜杠,则不会这样做。

删除主页后缀完全适用于除 ./dir 之外的每种格式。

我该如何解决这个问题?

google-cloud-platform

5
推荐指数
0
解决办法
337
查看次数

无法让 MongoDB 更改流文档出现在观察者服务中

我有一项服务需要监视 Mongo DB 上的集合以在系统中创建更改。我已设法使用 C# 驱动程序建立与副本集的连接,并使用以下代码来测试更改流。

public async Task WatchLoopAsync()
{
    var options = new ChangeStreamOptions
    {
        FullDocument = ChangeStreamFullDocumentOption.UpdateLookup,
    };
            
    using (var cursor = await _collection.WatchAsync(options))
    {
        _logger.LogInformation("Watching collection {String}", 
            _deployments.CollectionNamespace);
                
        await cursor.ForEachAsync(changeStreamDocument =>
        {
            var document = changeStreamDocument.FullDocument;
            _logger.LogInformation("Received document: {String}", 
                document.ToString());
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

第一个日志显示,表明它正在使用正确的命名空间监视集合。然后,我将一个文档添加到集合中,希望看到某些内容记录为“已接收文档:...”,但没有任何记录。

我遵循此处文档中给出的异步模式。

c# mongodb changestream

5
推荐指数
1
解决办法
1332
查看次数

使用 React 在输入上通过 onPaste 事件获得双倍值

我的 React 应用程序中有一个文本输入字段,我想验证其输入,因此我有一个验证器函数在 onChange 事件的处理程序中工作。我还想在将值粘贴到输入中时修剪空格,然后让它通过 onChange 验证器运行。

目前我的 JSX 看起来像这样:

handleChange(event) {
    let { name, value } = event.target
    if (typeof this.props.validatorFunction === "function") {
        value = this.props.validatorFunction(value) // the validator function in this case is {value => value.replace(" ", "-").toLowerCase()}
    }
    this.setState({
        [name] : value
    })
}

handlePaste(event) {
    let { name, value, selectionStart, selectionEnd } = event.target
    let pastedValue = event.clipboardData.getData("text")
    let pre = value.substring(0, selectionStart)
    let post = value.substring(selectionEnd, value.length)
    value = (pre + pastedValue + post).trim() …
Run Code Online (Sandbox Code Playgroud)

validation input reactjs

1
推荐指数
1
解决办法
3921
查看次数