简体   繁体   English

如何通过流星服务 HTTP 请求

[英]How to serve HTTP requests over meteor

I am creating a live streaming application using meteor.我正在使用meteor 创建一个实时流媒体应用程序。 Currently I have a need to create a live transcoding option, so I am trying to integrate this node.js module with our meteor application: https://github.com/mifi/hls-vod .目前我需要创建一个实时转码选项,所以我试图将此 node.js 模块与我们的流星应用程序集成: https : //github.com/mifi/hls-vod However, the way it works is that you actually call the app.get(hls/) from your HTML5 video tag's src.但是,它的工作方式是您实际上从 HTML5 视频标签的 src 调用 app.get(hls/)。 I am wondering if there is a way to expect the call to this get using meteor.我想知道是否有一种方法可以期待使用meteor 调用这个get。 Since I can't integrate express with meteor I am having some trouble doing this.由于我无法将 express 与meteor 集成,因此我在执行此操作时遇到了一些麻烦。 I am wondering if there is a way to have meteor receive HTTP requests and send back data as per the node module.我想知道是否有办法让流星接收 HTTP 请求并根据节点模块发回数据。

This post has been updated此贴已更新

To server http requests over meteor you need a router.要通过meteor 处理http 请求,您需要一个路由器。 I would recommend ironRouter.我会推荐铁路由器。 There was meteor router but Tom Coleman also built ironRouter.有流星路由器,但 Tom Coleman 也构建了 IronRouter。

You can use something like this:你可以使用这样的东西:

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');
    }
  });
});

Hopefully that should get the route working similar to the express router.希望这应该使路由与快速路由器类似。

Meteor Router is now deprecated for Iron Router .现在, Iron Router已弃用 Meteor Router

See here for Server Side Routing with Iron Router请参阅此处了解使用 Iron Router 的服务器端路由

您可以直接使用底层web 应用程序,如此处所示或者使用流路由器选择器进行 SSR 路由。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM