Rename widgets endpoint to honour its name

This commit is contained in:
Raul Ochoa 2015-10-26 13:42:06 +01:00
parent f9d3e419a0
commit 6d9182aba8
3 changed files with 10 additions and 40 deletions

View File

@ -70,15 +70,11 @@ LayergroupController.prototype.register = function(app) {
this.bbox.bind(this));
app.get(app.base_url_mapconfig +
'/:token/:layer/list/:listName', cors(), userMiddleware,
this.list.bind(this));
app.get(app.base_url_mapconfig +
'/:token/:layer/histogram/:histogramName', cors(), userMiddleware,
this.histogram.bind(this));
'/:token/:layer/widget/:widgetName', cors(), userMiddleware,
this.widget.bind(this));
};
LayergroupController.prototype.list = function(req, res) {
LayergroupController.prototype.widget = function(req, res) {
var self = this;
step(
@ -91,41 +87,13 @@ LayergroupController.prototype.list = function(req, res) {
var mapConfigProvider = new MapStoreMapConfigProvider(
self.mapStore, req.context.user, self.userLimitsApi, req.params
);
self.widgetBackend.getList(mapConfigProvider, req.params, this);
self.widgetBackend.getWidget(mapConfigProvider, req.params, this);
},
function finish(err, tile, stats) {
req.profiler.add(stats || {});
if (err) {
self.sendError(req, res, err, 'GET LIST');
} else {
self.sendResponse(req, res, tile, 200);
}
}
);
};
LayergroupController.prototype.histogram = function(req, res) {
var self = this;
step(
function setupParams() {
self.req2params(req, this);
},
function retrieveList(err) {
assert.ifError(err);
var mapConfigProvider = new MapStoreMapConfigProvider(
self.mapStore, req.context.user, self.userLimitsApi, req.params
);
self.widgetBackend.getHistogram(mapConfigProvider, req.params, this);
},
function finish(err, tile, stats) {
req.profiler.add(stats || {});
if (err) {
self.sendError(req, res, err, 'GET LIST');
self.sendError(req, res, err, 'GET WIDGET');
} else {
self.sendResponse(req, res, tile, 200);
}

View File

@ -83,7 +83,7 @@ describe('histograms', function() {
assert.response(server,
{
url: '/api/v1/map/' + layergroupId + '/0/histogram/pop_max',
url: '/api/v1/map/' + layergroupId + '/0/widget/pop_max',
method: 'GET',
headers: {
host: 'localhost'
@ -100,7 +100,9 @@ describe('histograms', function() {
return next(err);
}
console.log(JSON.parse(res.body));
var histogram = JSON.parse(res.body);
assert.ok(histogram.length);
next(null);
}

View File

@ -83,7 +83,7 @@ describe('lists', function() {
assert.response(server,
{
url: '/api/v1/map/' + layergroupId + '/0/list/names',
url: '/api/v1/map/' + layergroupId + '/0/widget/names',
method: 'GET',
headers: {
host: 'localhost'