From d0ac47d752ec9b2307981fd0412682baee469772 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 27 May 2013 01:12:59 +0200 Subject: [PATCH] Update restful.js Provide `action` attribute in `req.restful` for downstream middleware also for PUT, POST and DELETE CAUTION: This is rather a hack than a nice solution... I jsut want to point out, that the req.restful.action is pretty inconsistently set. --- lib/restful.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/restful.js b/lib/restful.js index f9f7ca8..f75300f 100644 --- a/lib/restful.js +++ b/lib/restful.js @@ -284,7 +284,7 @@ function _extend (router, resources, options, respond, routeInfo) { req = this.req; if (!options.strict) { - preprocessRequest(req, resource); + preprocessRequest(req, resource, 'create'); } var cloned = utile.clone(options); @@ -412,6 +412,9 @@ function _extend (router, resources, options, respond, routeInfo) { var req = this.req, res = this.res; + req.restful = {}; + req.restful.action = 'delete'; + var _id = exports.buildResourceId(routeInfo, arguments); resource.destroy(_id, function (err, result) { return err @@ -428,7 +431,7 @@ function _extend (router, resources, options, respond, routeInfo) { res = this.res; if (!options.strict) - preprocessRequest(req, resource); + preprocessRequest(req, resource, 'update'); var _id = exports.buildResourceId(routeInfo, arguments); resource.update(_id, req.body, function (err, result) {