diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index e3e12c26..04f25862 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -361,22 +361,6 @@ var CartodbWindshaft = function(serverOptions) { } } - ws.post(template_baseurl + '/:template_id', function(req, res) { - if ( req.profiler && req.profiler.statsd_client) { - req.profiler.start('windshaft-cartodb.instance_template_post'); - } - Step( - function() { - if ( ! req.headers['content-type'] || req.headers['content-type'].split(';')[0] != 'application/json') { - throw new Error('template POST data must be of type application/json, it is instead '); - } - instanciateTemplate(req, res, req.body, this); - }, function(err, response) { - finish_instanciation(err, response, res, req); - } - ); - }); - // ---- Template maps interface ends @} diff --git a/lib/cartodb/controllers/template_maps.js b/lib/cartodb/controllers/template_maps.js index 3c903fcd..63d481da 100644 --- a/lib/cartodb/controllers/template_maps.js +++ b/lib/cartodb/controllers/template_maps.js @@ -21,6 +21,7 @@ TemplateMapsController.prototype.register = function(app) { app.del(this.templateBaseUrl + '/:template_id', this.destroy.bind(this)); app.get(this.templateBaseUrl, this.list.bind(this)); app.options(this.templateBaseUrl + '/:template_id', this.options.bind(this)); + app.post(this.templateBaseUrl + '/:template_id', this.instantiate.bind(this)); }; // Add a template @@ -289,6 +290,24 @@ TemplateMapsController.prototype.list = function(req, res) { ); }; +TemplateMapsController.prototype.instantiate = function(req, res) { + var self = this; + + if ( req.profiler && req.profiler.statsd_client) { + req.profiler.start('windshaft-cartodb.instance_template_post'); + } + Step( + function() { + if ( ! req.headers['content-type'] || req.headers['content-type'].split(';')[0] != 'application/json') { + throw new Error('template POST data must be of type application/json, it is instead '); + } + self.instantiateTemplate(req, res, req.body, this); + }, function(err, response) { + self.finish_instantiation(err, response, res, req); + } + ); +}; + TemplateMapsController.prototype.options = function(req, res) { this.app.doCORS(res, "Content-Type"); return next();