Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Maps] Fix server log (#56679) #56699

Merged
merged 1 commit into from
Feb 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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