@nohost/router
Advanced tools
Comparing version 0.8.2 to 0.9.0
@@ -16,2 +16,9 @@ const url = require('url'); | ||
const CLIENT_ID = 'x-whistle-client-id'; | ||
const AUTH_URL = 'x-whistle-.script-auth-url'; | ||
const REQ_RULES_URL = 'x-whistle-.script-req-rules-url'; | ||
const RES_RULES_URL = 'x-whistle-.script-res-rules-url'; | ||
const STATS_URL = 'x-whistle-.script-stats-url'; | ||
const DATA_URL = 'x-whistle-.script-data-url'; | ||
const POLICY = 'x-whistle-.script-policy'; | ||
const URL_RE = /^http:(?:\/\/|%3A%2F%2F)[\w.-]/; | ||
const CLIENT_ID_FILTER = 'x-whistle-filter-client-id'; | ||
@@ -56,2 +63,27 @@ const ROUTE_RE = /([?&])route=([^?&]+)($|&)/; | ||
addHeader(CLIENT_ID, options.clientId); | ||
let useRemote; | ||
if (URL_RE.test(options.authUrl)) { | ||
addHeader(AUTH_URL, options.authUrl); | ||
useRemote = true; | ||
} | ||
const rulesUrl = options.rulesUrl || options.reqRulesUrl; | ||
if (URL_RE.test(rulesUrl)) { | ||
addHeader(REQ_RULES_URL, rulesUrl); | ||
useRemote = true; | ||
} | ||
if (URL_RE.test(options.resRulesUrl)) { | ||
addHeader(RES_RULES_URL, options.resRulesUrl); | ||
useRemote = true; | ||
} | ||
if (URL_RE.test(options.statsUrl)) { | ||
addHeader(STATS_URL, options.statsUrl); | ||
useRemote = true; | ||
} | ||
if (URL_RE.test(options.dataUrl)) { | ||
addHeader(DATA_URL, options.dataUrl); | ||
useRemote = true; | ||
} | ||
if (useRemote) { | ||
headers[POLICY] = 'remote'; | ||
} | ||
} | ||
@@ -58,0 +90,0 @@ addHeader(SPACE_NAME, options.spaceName); |
{ | ||
"name": "@nohost/router", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"description": "Nohost cluster router", | ||
@@ -5,0 +5,0 @@ "main": "lib/", |
16885
425