Make a middleware to respond layergroup

This commit is contained in:
Daniel García Aubert
2017-11-01 20:06:32 +01:00
parent 46c76d6a4c
commit c8000e5cf8

View File

@@ -60,6 +60,7 @@ MapController.prototype.register = function(app) {
this.prepareAdapterMapConfig.bind(this),
this.createLayergroup.bind(this),
this.createGet.bind(this),
respond,
mapErrorMiddleware({
label: 'ANONYMOUS LAYERGROUP',
augmentError: true
@@ -74,6 +75,7 @@ MapController.prototype.register = function(app) {
this.prepareAdapterMapConfig.bind(this),
this.createLayergroup.bind(this),
this.createPost.bind(this),
respond,
mapErrorMiddleware({
label: 'ANONYMOUS LAYERGROUP',
augmentError: true
@@ -88,6 +90,7 @@ MapController.prototype.register = function(app) {
this.getTemplate.bind(this),
this.createLayergroupFromTemplate.bind(this),
this.jsonp.bind(this),
respond,
mapErrorMiddleware({
label: 'NAMED MAP LAYERGROUP'
})
@@ -101,6 +104,7 @@ MapController.prototype.register = function(app) {
this.getTemplate.bind(this),
this.createLayergroupFromTemplate.bind(this),
this.instantiate.bind(this),
respond,
mapErrorMiddleware({
label: 'NAMED MAP LAYERGROUP'
})
@@ -250,16 +254,7 @@ MapController.prototype.create = function(req, res, next) {
if (err) {
return next(err);
}
const { layergroup } = res.locals;
res.status(200);
if (req.query && req.query.callback) {
res.jsonp(layergroup);
} else {
res.json(layergroup);
}
next();
}
);
};
@@ -333,20 +328,23 @@ MapController.prototype.instantiateTemplate = function(req, res, next) {
if (err) {
return next(err);
}
const { layergroup } = res.locals;
res.status(200);
if (req.query && req.query.callback) {
res.jsonp(layergroup);
} else {
res.json(layergroup);
}
next();
}
);
};
function respond (req, res) {
const { layergroup } = res.locals;
res.status(200);
if (req.query && req.query.callback) {
res.jsonp(layergroup);
} else {
res.json(layergroup);
}
}
MapController.prototype.afterLayergroupCreateBuilder = function (options = {}) {
const self = this;
const {