X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fframework%2Fcore%2Fapi_utils%2Futils.js;fp=skyquake%2Fframework%2Fcore%2Fapi_utils%2Futils.js;h=488cd9eff2b26973662079f03591713fd68cfc67;hb=168f7b61f09549d4bf25ecd0805435b2cc3a5243;hp=68775f8fede9ea3227de1329fdf69b67c2080d47;hpb=aa95200177f42de39a102a559713bde13dedb30d;p=osm%2FUI.git diff --git a/skyquake/framework/core/api_utils/utils.js b/skyquake/framework/core/api_utils/utils.js index 68775f8fe..488cd9eff 100644 --- a/skyquake/framework/core/api_utils/utils.js +++ b/skyquake/framework/core/api_utils/utils.js @@ -49,6 +49,14 @@ var confdPort = function(api_server) { return api_server + ':' + CONFD_PORT; }; +var projectContextUrl = function(req, url) { + if (req.session && req.session.projectId) { + return url.replace(/(\/api\/operational\/|\/api\/config\/|\/api\/operations\/)(.*)/, '$1project/pname/$2'); + + } + return url; +} + var validateResponse = function(callerName, error, response, body, resolve, reject) { var res = {}; @@ -197,7 +205,7 @@ var passThroughConstructor = function(app) { } new Promise(function(resolve, reject) { request({ - uri: uri, + uri: projectContextUrl(req, uri), method: 'GET', headers: _.extend({}, CONSTANTS.HTTP_HEADERS.accept[type], { 'Authorization': req.session && req.session.authorization, @@ -244,5 +252,7 @@ module.exports = { passThroughConstructor: passThroughConstructor, - getPortForProtocol: getPortForProtocol + getPortForProtocol: getPortForProtocol, + + projectContextUrl: projectContextUrl };