Use req2params middleware for layergroup create endpoint
This commit is contained in:
@@ -20,6 +20,7 @@ var NamedMapsCacheEntry = require('../cache/model/named_maps_entry');
|
||||
var NamedMapMapConfigProvider = require('../models/mapconfig/provider/named-map-provider');
|
||||
var CreateLayergroupMapConfigProvider = require('../models/mapconfig/provider/create-layergroup-provider');
|
||||
|
||||
const req2paramsMiddleware = require('../middleware/req2params-middleware');
|
||||
|
||||
/**
|
||||
* @param {AuthApi} authApi
|
||||
@@ -52,6 +53,7 @@ function MapController(authApi, pgConnection, templateMaps, mapBackend, metadata
|
||||
this.resourceLocator = new ResourceLocator(global.environment);
|
||||
|
||||
this.statsBackend = statsBackend;
|
||||
this.req2paramsMiddleware = req2paramsMiddleware(authApi, pgConnection);
|
||||
}
|
||||
|
||||
util.inherits(MapController, BaseController);
|
||||
@@ -60,8 +62,21 @@ module.exports = MapController;
|
||||
|
||||
|
||||
MapController.prototype.register = function(app) {
|
||||
app.get(app.base_url_mapconfig, cors(), userMiddleware, this.createGet.bind(this));
|
||||
app.post(app.base_url_mapconfig, cors(), userMiddleware, this.createPost.bind(this));
|
||||
app.get(
|
||||
app.base_url_mapconfig,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
this.req2paramsMiddleware,
|
||||
this.createGet.bind(this)
|
||||
);
|
||||
app.post(
|
||||
app.base_url_mapconfig,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
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.options(app.base_url_mapconfig, cors('Content-Type'));
|
||||
@@ -70,8 +85,7 @@ MapController.prototype.register = function(app) {
|
||||
MapController.prototype.createGet = function(req, res, next){
|
||||
req.profiler.start('windshaft.createmap_get');
|
||||
|
||||
this.create(req, res, function createGet$prepareConfig(err, req) {
|
||||
assert.ifError(err);
|
||||
this.create(req, res, function createGet$prepareConfig(req) {
|
||||
if ( ! req.params.config ) {
|
||||
throw new Error('layergroup GET needs a "config" parameter');
|
||||
}
|
||||
@@ -82,8 +96,7 @@ MapController.prototype.createGet = function(req, res, next){
|
||||
MapController.prototype.createPost = function(req, res, next) {
|
||||
req.profiler.start('windshaft.createmap_post');
|
||||
|
||||
this.create(req, res, function createPost$prepareConfig(err, req) {
|
||||
assert.ifError(err);
|
||||
this.create(req, res, function createPost$prepareConfig(req) {
|
||||
if (!req.is('application/json')) {
|
||||
throw new Error('layergroup POST data must be of type application/json');
|
||||
}
|
||||
@@ -132,10 +145,10 @@ MapController.prototype.create = function(req, res, prepareConfigFn, next) {
|
||||
var context = {};
|
||||
|
||||
step(
|
||||
function setupParams(){
|
||||
self.req2params(req, res, this);
|
||||
function prepareConfig () {
|
||||
const requestMapConfig = prepareConfigFn(req);
|
||||
return requestMapConfig;
|
||||
},
|
||||
prepareConfigFn,
|
||||
function prepareAdapterMapConfig(err, requestMapConfig) {
|
||||
assert.ifError(err);
|
||||
context.analysisConfiguration = {
|
||||
|
||||
Reference in New Issue
Block a user