Is it possible to define iron-router server side routes that respond to certain HTTP actions?

自古美人都是妖i 提交于 2019-12-01 23:48:22

You can definitely check the method and only respond if it's the one you want, e.g., like this:

Router.map(function () {
    this.route('route', {
        path: '/mypath',
        where: 'server',
        action: function() {
            if (this.request.method != 'GET') {
                // do whatever
            } else {
                this.response.writeHead(404);
            }
        }
    })
});

The second question beats me. It might be possible to use this.next() somehow, but I'm not sure.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!