Extract getTile middleware from controller's context
This commit is contained in:
@@ -43,6 +43,7 @@ module.exports = NamedMapsController;
|
||||
NamedMapsController.prototype.register = function(app) {
|
||||
const tileOptions = {
|
||||
namedMapProviderCache: this.namedMapProviderCache,
|
||||
tileBackend: this.tileBackend,
|
||||
label: 'NAMED_MAP_TILE'
|
||||
};
|
||||
|
||||
@@ -53,7 +54,7 @@ NamedMapsController.prototype.register = function(app) {
|
||||
this.prepareContext,
|
||||
getNamedMapProvider(tileOptions),
|
||||
getAffectedTables(),
|
||||
this.getTile(tileOptions),
|
||||
getTile(tileOptions),
|
||||
this.setSurrogateKey(),
|
||||
this.setCacheChannelHeader(),
|
||||
this.setLastModifiedHeader(),
|
||||
@@ -194,11 +195,11 @@ function prepareLayerFilterFromPreviewLayers ({ namedMapProviderCache, label })
|
||||
};
|
||||
};
|
||||
|
||||
NamedMapsController.prototype.getTile = function ({ label }) {
|
||||
function getTile ({ tileBackend, label }) {
|
||||
return function getTileMiddleware (req, res, next) {
|
||||
const { namedMapProvider } = res.locals;
|
||||
|
||||
this.tileBackend.getTile(namedMapProvider, req.params, (err, tile, headers, stats) => {
|
||||
tileBackend.getTile(namedMapProvider, req.params, (err, tile, headers, stats) => {
|
||||
req.profiler.add(stats);
|
||||
|
||||
if (err) {
|
||||
@@ -212,7 +213,7 @@ NamedMapsController.prototype.getTile = function ({ label }) {
|
||||
|
||||
next();
|
||||
});
|
||||
}.bind(this);
|
||||
};
|
||||
};
|
||||
|
||||
NamedMapsController.prototype.getStaticImageOptions = function () {
|
||||
|
||||
Reference in New Issue
Block a user