Use req2params middleware for instantiate named map endpoint
This commit is contained in:
@@ -76,9 +76,20 @@ MapController.prototype.register = function(app) {
|
||||
this.req2paramsMiddleware,
|
||||
this.createPost.bind(this)
|
||||
);
|
||||
|
||||
app.get(app.base_url_templated + '/:template_id/jsonp', cors(), userMiddleware, this.jsonp.bind(this));
|
||||
app.post(app.base_url_templated + '/:template_id', cors(), userMiddleware, this.instantiate.bind(this));
|
||||
app.get(
|
||||
app.base_url_templated + '/:template_id/jsonp',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
this.req2paramsMiddleware,
|
||||
this.jsonp.bind(this)
|
||||
);
|
||||
app.post(
|
||||
app.base_url_templated + '/:template_id',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
this.req2paramsMiddleware,
|
||||
this.instantiate.bind(this)
|
||||
);
|
||||
app.options(app.base_url_mapconfig, cors('Content-Type'));
|
||||
};
|
||||
|
||||
@@ -234,9 +245,6 @@ MapController.prototype.instantiateTemplate = function(req, res, prepareParamsFn
|
||||
var mapConfigProvider;
|
||||
var mapConfig;
|
||||
step(
|
||||
function setupParams(){
|
||||
self.req2params(req, res, this);
|
||||
},
|
||||
function getTemplateParams() {
|
||||
prepareParamsFn(this);
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@ const _ = require('underscore');
|
||||
const debug = require('debug')('windshaft:cartodb:error-middleware');
|
||||
|
||||
module.exports = function errorMiddleware (/* options */) {
|
||||
return function (err, req, res, next) {
|
||||
return function error (err, req, res, next) {
|
||||
// jshint unused:false
|
||||
// jshint maxcomplexity:9
|
||||
var allErrors = Array.isArray(err) ? err : [err];
|
||||
@@ -122,6 +122,7 @@ function statusFromErrorMessage(errMsg) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,9 @@ module.exports = function req2paramsMiddleware (authApi, pgConnection) {
|
||||
},
|
||||
function finishSetup(err) {
|
||||
if ( err ) {
|
||||
if (err.message && -1 !== err.message.indexOf('name not found')) {
|
||||
err.http_status = 404;
|
||||
}
|
||||
req.profiler.done('req2params');
|
||||
return next(err, req);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user