Login 使用iron路由器登录meteor服务器端
我想创建一个服务器端登录,为我的客户端应用程序使用iron router:server。 但直到现在我还没有找到任何线索。然而,我使用reststop2,但现在他说使用铁路由器 这是我的简单代码:Login 使用iron路由器登录meteor服务器端,login,meteor,iron-router,Login,Meteor,Iron Router,我想创建一个服务器端登录,为我的客户端应用程序使用iron router:server。 但直到现在我还没有找到任何线索。然而,我使用reststop2,但现在他说使用铁路由器 这是我的简单代码: Router.route('/api/signin', {where: 'server'}) .get(function () { this.response.end('get request\n'); }) .post(function () {
Router.route('/api/signin', {where: 'server'})
.get(function () {
this.response.end('get request\n');
})
.post(function () {
console.log(this.request.body.username);//or email maybe
console.log(this.request.body.password);
this.response.end('post request\n');
});
我使用json从body发送或发布数据,这就是为什么我使用this.request.body.*
现在让我知道,如何使用该用户名和密码登录服务器端
仅供参考,在reststop2中,我只需使用localhost:3000/api/login
并发送数据用户名和密码,然后获得returnaccess-token
和user-id
谢谢您可以使用iron:router构建API:
Router.map(function () {
this.route('/api/login/:username/:password', {
where : 'server,
action : function(){
//your code goes here
}
}
});
我总是会选择一个实现API的包,而不是iron:router,但对于简单的服务器端内容,iron:route可以做到。我发布了一个开源包,用于在Meteor 0.9.0+中编写REST API,我想这可能正是您想要的。当RestStop2被弃用时,我遇到了同样的问题: 它的灵感来源于和使用的服务器端路由。如果您已经在使用RestStop2,那么很容易将其转换为