mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-13 12:37:17 +08:00
Throw error on PUT without id.
This commit is contained in:
@@ -130,7 +130,7 @@ Collection.prototype.sanitize = function (body) {
|
||||
Collection.prototype.handle = function (ctx) {
|
||||
|
||||
// set id one wasnt provided in the query
|
||||
ctx.query.id = ctx.query.id || this.parseId(ctx);
|
||||
ctx.query.id = ctx.query.id || this.parseId(ctx) || (ctx.body && ctx.body.id);
|
||||
|
||||
if (ctx.req.internal) {
|
||||
ctx.session.internal = true;
|
||||
@@ -140,8 +140,12 @@ Collection.prototype.handle = function (ctx) {
|
||||
case 'GET':
|
||||
this.find(ctx.session, ctx.query, ctx.dpd, ctx.done);
|
||||
break;
|
||||
case 'POST':
|
||||
case 'PUT':
|
||||
if (!ctx.query.id) {
|
||||
ctx.done("must provide id to update an object");
|
||||
break;
|
||||
}
|
||||
case 'POST':
|
||||
this.save(ctx.session, ctx.body, ctx.query, ctx.dpd, ctx.done);
|
||||
break;
|
||||
case 'DELETE':
|
||||
|
||||
Reference in New Issue
Block a user