X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=skyquake%2Fframework%2Fcore%2Fapi_utils%2Futils.js;h=488cd9eff2b26973662079f03591713fd68cfc67;hb=abf00ef39ee93f2a7ff05a4432eb3a50a88a487e;hp=68775f8fede9ea3227de1329fdf69b67c2080d47;hpb=5a83ca0dc3306b54e1db18b9e05e860fed21324e;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 };