Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart 如何在Redstone中将http请求重定向到https?_Dart_Redstone.dart - Fatal编程技术网

Dart 如何在Redstone中将http请求重定向到https?

Dart 如何在Redstone中将http请求重定向到https?,dart,redstone.dart,Dart,Redstone.dart,在expressjs中,我可以 app.use(function(req, res, next) { if((!req.secure) && (req.get('X-Forwarded-Proto') !== 'https')) { res.redirect('https://' + req.get('Host') + req.url); console.log('redirected http request to https');

在expressjs中,我可以

app.use(function(req, res, next) {
    if((!req.secure) && (req.get('X-Forwarded-Proto') !== 'https')) {
        res.redirect('https://' + req.get('Host') + req.url);
        console.log('redirected http request to https');
    } else {
        next();
    }
});
将http请求重定向到https

我如何在readstone中实现它

我试着跟随,但不起作用

@app.Route('/')
adlMain() {
  if (app.request.requestedUri.scheme != 'https') {
    var httpsUrl = app.request.requestedUri.replace(scheme:   'https').toString();
    app.redirect(httpsUrl);
  }
  return new File('build/web/index.html');
}

您需要返回应用程序重定向的结果:

return app.redirect(httpsUrl);
这与Express中的不同,因为Express使用响应对象向其写入标题和内容,而Redstone使用返回值