java发送HTTP get请求到meteor服务器

时间:2015-02-03 07:33:54

标签: java meteor

问题1:Meteor服务器是否接受来自外部客户端的http get请求,例如我的java应用程序? 问题2:如果Meteor服务器接受http get请求,如何在流星服务器中设置处理和响应它的方法?我已经弄明白了如何在java中发送https get请求。请给我一个该服务器方法的样本。

编辑:我发现了一种中间件方法,

  WebApp.connectHandlers.stack.splice(0, 0, {
      route: '/api/endpoint',
      handle: function(req, res, next) {
        res.writeHead(200, {'Content-Type': 'application/json'});
        res.end('{"success": true}');
      },
  });

我试着将它放在我的流星服务器中,但我无法弄清楚它是如何工作的......

1 个答案:

答案 0 :(得分:0)

如果您使用的是铁路由器包,则可以建立服务器端路由来处理HTTP请求:https://github.com/EventedMind/iron-router/blob/devel/Guide.md#restful-routes

Router.route('/webhooks/stripe', { where: 'server' })
  .get(function () {
    // GET /webhooks/stripe
  })
  .post(function () {
    // POST /webhooks/stripe
  })
  .put(function () {
    // PUT /webhooks/stripe
  })