diff --git a/lib/cartodb/api/map/tile-layergroup-controller.js b/lib/cartodb/api/map/tile-layergroup-controller.js index 2c049019..f882d13c 100644 --- a/lib/cartodb/api/map/tile-layergroup-controller.js +++ b/lib/cartodb/api/map/tile-layergroup-controller.js @@ -45,8 +45,11 @@ module.exports = class TileLayergroupController { // REGEXP doesn't match with `val` const not = (val) => `(?!${val})([^\/]+?)`; - mapRouter.get( - [ `/:token/:z/:x/:y@:scale_factor?x.:format`, `/:token/:z/:x/:y.:format` ], + mapRouter.get([ + `/:token/:z/:x/:y@:scale_factor?x.:format`, + `/:token/:z/:x/:y.:format`, + `/:token${not('static')}/:layer/:z/:x/:y.(:format)` + ], layergroupToken(), coordinates(), credentials(), @@ -60,33 +63,7 @@ module.exports = class TileLayergroupController { this.pgConnection, this.layergroupAffectedTablesCache ), - getTile(this.tileBackend, 'map_tile'), - cacheControlHeader(), - cacheChannelHeader(), - surrogateKeyHeader({ surrogateKeysCache: this.surrogateKeysCache }), - lastModifiedHeader(), - incrementSuccessMetrics(global.statsClient), - incrementErrorMetrics(global.statsClient), - tileError(), - vectorError() - ); - - mapRouter.get( - `/:token${not('static')}/:layer/:z/:x/:y.(:format)`, - layergroupToken(), - coordinates(), - credentials(), - authorize(this.authBackend), - dbConnSetup(this.pgConnection), - rateLimit(this.userLimitsBackend, RATE_LIMIT_ENDPOINTS_GROUPS.TILE), - cleanUpQueryParams(), - createMapStoreMapConfigProvider( - this.mapStore, - this.userLimitsBackend, - this.pgConnection, - this.layergroupAffectedTablesCache - ), - getTile(this.tileBackend, 'maplayer_tile'), + getTile(this.tileBackend), cacheControlHeader(), cacheChannelHeader(), surrogateKeyHeader({ surrogateKeysCache: this.surrogateKeysCache }), @@ -108,9 +85,9 @@ function getStatusCode(tile, format){ return tile.length === 0 && format === 'mvt' ? 204 : 200; } -function getTile (tileBackend, profileLabel = 'tile') { +function getTile (tileBackend) { return function getTileMiddleware (req, res, next) { - req.profiler.start(`windshaft.${profileLabel}`); + req.profiler.start(`windshaft.${req.params.layer ? 'maplayer_tile' : 'map_tile'}`); const { mapConfigProvider } = res.locals; const { token } = res.locals;