Skip to content

Commit

Permalink
[Maps] Fix server log (#56679)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored Feb 3, 2020
1 parent f443d8a commit 7b69e96
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions x-pack/legacy/plugins/maps/server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export function initRoutes(server, licenseUid) {
method: 'GET',
path: `${ROOT}/${EMS_FILES_API_PATH}/${EMS_FILES_DEFAULT_JSON_PATH}`,
handler: async request => {
checkEMSProxyConfig();
const { server } = request;
checkEMSProxyConfig(server);

if (!request.query.id) {
server.log('warning', 'Must supply id parameters to retrieve EMS file');
Expand All @@ -96,7 +97,8 @@ export function initRoutes(server, licenseUid) {
method: 'GET',
path: `${ROOT}/${EMS_TILES_API_PATH}/${EMS_TILES_RASTER_TILE_PATH}`,
handler: async (request, h) => {
checkEMSProxyConfig();
const { server } = request;
checkEMSProxyConfig(server);

if (
!request.query.id ||
Expand Down Expand Up @@ -127,8 +129,9 @@ export function initRoutes(server, licenseUid) {
server.route({
method: 'GET',
path: `${ROOT}/${EMS_CATALOGUE_PATH}`,
handler: async () => {
checkEMSProxyConfig();
handler: async request => {
const { server } = request;
checkEMSProxyConfig(server);

const main = await emsClient.getMainManifest();
const proxiedManifest = {
Expand Down Expand Up @@ -157,8 +160,9 @@ export function initRoutes(server, licenseUid) {
server.route({
method: 'GET',
path: `${ROOT}/${EMS_FILES_CATALOGUE_PATH}/{emsVersion}/manifest`,
handler: async () => {
checkEMSProxyConfig();
handler: async request => {
const { server } = request;
checkEMSProxyConfig(server);

const file = await emsClient.getDefaultFileManifest();
const layers = file.layers.map(layer => {
Expand All @@ -181,8 +185,9 @@ export function initRoutes(server, licenseUid) {
server.route({
method: 'GET',
path: `${ROOT}/${EMS_TILES_CATALOGUE_PATH}/{emsVersion}/manifest`,
handler: async () => {
checkEMSProxyConfig();
handler: async request => {
const { server } = request;
checkEMSProxyConfig(server);

const tilesManifest = await emsClient.getDefaultTMSManifest();
const newServices = tilesManifest.services.map(service => {
Expand Down Expand Up @@ -220,7 +225,8 @@ export function initRoutes(server, licenseUid) {
method: 'GET',
path: `${ROOT}/${EMS_TILES_API_PATH}/${EMS_TILES_RASTER_STYLE_PATH}`,
handler: async request => {
checkEMSProxyConfig();
const { server } = request;
checkEMSProxyConfig(server);

if (!request.query.id) {
server.log('warning', 'Must supply id parameter to retrieve EMS raster style');
Expand All @@ -246,7 +252,8 @@ export function initRoutes(server, licenseUid) {
method: 'GET',
path: `${ROOT}/${EMS_TILES_API_PATH}/${EMS_TILES_VECTOR_STYLE_PATH}`,
handler: async request => {
checkEMSProxyConfig();
const { server } = request;
checkEMSProxyConfig(server);

if (!request.query.id) {
server.log('warning', 'Must supply id parameter to retrieve EMS vector style');
Expand Down Expand Up @@ -285,7 +292,8 @@ export function initRoutes(server, licenseUid) {
method: 'GET',
path: `${ROOT}/${EMS_TILES_API_PATH}/${EMS_TILES_VECTOR_SOURCE_PATH}`,
handler: async request => {
checkEMSProxyConfig();
const { server } = request;
checkEMSProxyConfig(server);

if (!request.query.id || !request.query.sourceId) {
server.log(
Expand Down Expand Up @@ -316,7 +324,8 @@ export function initRoutes(server, licenseUid) {
method: 'GET',
path: `${ROOT}/${EMS_TILES_API_PATH}/${EMS_TILES_VECTOR_TILE_PATH}`,
handler: async (request, h) => {
checkEMSProxyConfig();
const { server } = request;
checkEMSProxyConfig(server);

if (
!request.query.id ||
Expand Down Expand Up @@ -352,7 +361,8 @@ export function initRoutes(server, licenseUid) {
method: 'GET',
path: `${ROOT}/${EMS_TILES_API_PATH}/${EMS_GLYPHS_PATH}/{fontstack}/{range}`,
handler: async (request, h) => {
checkEMSProxyConfig();
const { server } = request;
checkEMSProxyConfig(server);
const url = mapConfig.emsFontLibraryUrl
.replace('{fontstack}', request.params.fontstack)
.replace('{range}', request.params.range);
Expand All @@ -365,7 +375,8 @@ export function initRoutes(server, licenseUid) {
method: 'GET',
path: `${ROOT}/${EMS_TILES_API_PATH}/${EMS_SPRITES_PATH}/{id}/sprite{scaling?}.{extension}`,
handler: async (request, h) => {
checkEMSProxyConfig();
const { server } = request;
checkEMSProxyConfig(server);

if (!request.params.id) {
server.log('warning', 'Must supply id parameter to retrieve EMS vector source sprite');
Expand Down Expand Up @@ -443,7 +454,7 @@ export function initRoutes(server, licenseUid) {
},
});

function checkEMSProxyConfig() {
function checkEMSProxyConfig(server) {
if (!mapConfig.proxyElasticMapsServiceInMaps) {
server.log(
'warning',
Expand Down

0 comments on commit 7b69e96

Please sign in to comment.