From 6e24f6ec8e16d9cd8bab530884bbedd9e23b39a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=CC=8Ans=20Beckman?= Date: Sat, 18 Aug 2018 12:02:54 +0200 Subject: [PATCH] Update endpoint URL and change content type After a good nights sleep I considered the structure of the endpoint link for WMTS, at the same time I cleaned up the code and added the correct content type for the response. --- docs/endpoints.rst | 2 +- public/templates/index.tmpl | 2 +- src/server.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/endpoints.rst b/docs/endpoints.rst index b6d3bbd..b3a5fa0 100644 --- a/docs/endpoints.rst +++ b/docs/endpoints.rst @@ -23,7 +23,7 @@ Rendered tiles WMTS Capabilities ============== -* WMTS Capabilities are served at ``/wmts/{id}/`` +* WMTS Capabilities are served at ``/styles/{id}/wmts.xml`` Static images ============= diff --git a/public/templates/index.tmpl b/public/templates/index.tmpl index 3dcef0d..2c61428 100644 --- a/public/templates/index.tmpl +++ b/public/templates/index.tmpl @@ -41,7 +41,7 @@ {{#if serving_data}}| {{/if}}TileJSON {{/if}} {{#if serving_rendered}} - | WMTS + | WMTS {{/if}} {{#if xyz_link}} | XYZ diff --git a/src/server.js b/src/server.js index 8d8ac3b..70edfe8 100644 --- a/src/server.js +++ b/src/server.js @@ -269,6 +269,7 @@ function start(opts) { data['key_query_part'] = req.query.key ? 'key=' + req.query.key + '&' : ''; data['key_query'] = req.query.key ? '?key=' + req.query.key : ''; + if(template === 'wmts')res.set('Content-Type', 'text/xml'); return res.status(200).send(compiled(data)); }); resolve(); @@ -369,7 +370,7 @@ function start(opts) { return res.redirect(301, '/styles/' + req.params.id + '/'); }); */ - serveTemplate('/wmts/:id/$', 'wmts', function(req) { + serveTemplate('/styles/:id/wmts.xml', 'wmts', function(req) { var id = req.params.id; var wmts = clone((config.styles || {})[id]); if (!wmts) { @@ -381,7 +382,6 @@ function start(opts) { wmts.id = id; wmts.name = (serving.styles[id] || serving.rendered[id]).name; wmts.baseUrl = (req.get('X-Forwarded-Protocol')?req.get('X-Forwarded-Protocol'):req.protocol) + '://' + req.get('host'); - console.log(wmts) return wmts; });