在阅读了很多关于REST版本的材料之后,我正在考虑对调用进行版本控制而不是API.例如:
http://api.mydomain.com/callfoo/v2.0/param1/param2/param3
http://api.mydomain.com/verifyfoo/v1.0/param1/param2
Run Code Online (Sandbox Code Playgroud)
而不是第一次拥有
http://api.mydomain.com/v1.0/callfoo/param1/param2
http://api.mydomain.com/v1.0/verifyfoo/param1/param2
Run Code Online (Sandbox Code Playgroud)
然后去
http://api.mydomain.com/v2.0/callfoo/param1/param2/param3
http://api.mydomain.com/v2.0/verifyfoo/param1/param2
Run Code Online (Sandbox Code Playgroud)
我看到的优点是:
我错过了什么吗?请指教.
我有一个简短的javascript代码,我需要在for循环中跳到下一个....见下文:
var y = new Array ('1', '2', '3', '4');
for (var x in y) {
callFunctionOne(y[x]);
while (condition){
condition = callFunctionTwo(y[x]);
//now want to move to the next item so
// invoke callFunctionTwo() again...
}
}
Run Code Online (Sandbox Code Playgroud)
希望保持简单,因此语法可能没有错误.
我有mongoose更新调用,并希望传递一个额外的参数...像这样:
试图传递isLoopOver
UserInfo.update({_id: userInfo._id}, {'value': someval}, function(err, numAffected, isLoopOver ) {
console.log('IsLoopOver ' + JSON.stringify(isLoopOver) );
if (isLoopOver){
doSomething(isLoopOver);
}
});
Run Code Online (Sandbox Code Playgroud)
试过上面但我得到一个对象(在回调内)如下:
{"updatedExisting":true,"n":1,"connectionId":117,"err":null,"ok":1}
Run Code Online (Sandbox Code Playgroud)
不知道为什么它会显示mongo的状态.
问题:如何通过回调传递额外参数?
似乎 Nginx 在与正则表达式一起使用时总是对 url 进行解编码。我有一个重写规则:
location /api/ {
rewrite /api/(.*)$ $1 break;
proxy_pass http://127.0.0.1:8000/$1;
}
Run Code Online (Sandbox Code Playgroud)
我想从 usl 中删除 api 但保留路径的其余部分。路径的一部分是电子邮件地址 someone@somewhere.com。我正在通过某人 %40somewhere.com 但 Nginx 正在用 @ 符号将它转回来。
我有一个非常简单的设置......
设置一个路径,使用bootstrap调用模式对话框.单击菜单时headerView调用方法 -
menuClick: function(e){
e.preventDefault();
if (!this.myView) {
this.myView= new MyView({model: new MyModel()});
}
this.myView.render();
},
Run Code Online (Sandbox Code Playgroud)
在MyView中,我在初始化中调用bind
initialize: function(){
this.model.bind('sync', function(model){ alert('test view')});
}
Run Code Online (Sandbox Code Playgroud)
并在按钮单击事件中调用Backbone.sync:
var response = Backbone.sync('read', this.model, {
success: function(data, textStatus, jqXHR) { alert('success'); },
error: function(data, textStatus, jqXHR){ alert(fail); }
});
Run Code Online (Sandbox Code Playgroud)
同步内的警报被调用...但是初始化中的bind命令中的警报永远不会被调用.尝试在模型中移动绑定,将其移出,也尝试同步:失败,同步:完成.没有成功.
我有一个奇怪的情况...
我有 Express.js、Node.js 和 Mongoose Web 应用程序。
其中一条路由有一个调用 respond.send(...) 的猫鼬回调。但是,因为回调后没有其他内容,我怀疑它会自动转到 next() 路由。
前任:
//getItem
app.get('/api/ItemOne', isUserValid, routes.getItem);
//getAnotherItem
app.get('/api/getAnotherItem', isUserValid, routes.getAnotherItem);
//Routes
exports.getItem = function (req, res) {
//console.log ('In getItem');
getItem .findOne({ some_id : some_id}, function(err, getItem ){
//console.log ('In getItem callback');
res.send({
itemName : getItem .itemName,
itemValue : getItem .itemValue;
});
})
});
exports.getAnotherItem = function (req, res) {
//console.log ('In getAnotherItem');
getAnotherItem.findOne({ some_id : some_id}, function(err, getAnotherItemRet){
//console.log ('In getAnotherItem Callback');
res.send({
itemName : getAnotherItemRet.itemName,
itemValue : …Run Code Online (Sandbox Code Playgroud) 我有兴趣找出包含完整 URL 路径的 Google 搜索结果的数量。我知道我们确实在搜索完全合格的域或子域。但是,一直无法找到搜索路径或文件的方法。
例如:我想知道有多少 Google 搜索结果包含 "play.google.com/store/apps/details?id=com.konsier.konsier_infocard"。
mongoose ×2
node.js ×2
api ×1
backbone.js ×1
express ×1
for-in-loop ×1
for-loop ×1
javascript ×1
mongodb ×1
nginx ×1
rest ×1