我正在使用 meteor 创建一个实时流媒体应用程序。目前我需要创建一个实时转码选项,所以我正在尝试将这个 node.js 模块与我们的 meteor 应用程序集成:https://github.com/mifi/hls-vod .但是,它的工作方式是您实际从 HTML5 视频标签的 src 调用 app.get(hls/)。我想知道是否有一种方法可以期待使用 meteor 调用这个 get。由于我无法将 express 与 meteor 集成,因此我在执行此操作时遇到了一些麻烦。我想知道是否有办法让 meteor 接收 HTTP 请求并根据 Node 模块发回数据。
最佳答案
这篇文章已经更新
要通过 meteor 处理 http 请求,您需要一个路由器。我会推荐 ironRouter。有 meteor 路由器,但 Tom Coleman 也构建了 ironRouter。
你可以这样使用:
Router.map(function () {
this.route('serverFile', {
path: '/pathonserver',
action: function () {
console.log(this.params); //Contains params
this.response.writeHead(200, {'Content-Type': 'text/html'});
this.response.end('hello from server');
}
});
});
希望这能让路由像 express 路由器一样工作。
关于javascript - 如何通过 meteor 服务 HTTP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15059125/