You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
600 B
JavaScript
23 lines
600 B
JavaScript
|
5 years ago
|
'use strict';
|
||
|
|
|
||
|
|
var url = require('url');
|
||
|
|
var debug = require('debug')('express-http-proxy');
|
||
|
|
|
||
|
|
function defaultProxyReqPathResolver(req) {
|
||
|
|
return url.parse(req.url).path;
|
||
|
|
}
|
||
|
|
|
||
|
|
function resolveProxyReqPath(container) {
|
||
|
|
var resolverFn = container.options.proxyReqPathResolver || defaultProxyReqPathResolver;
|
||
|
|
|
||
|
|
return Promise
|
||
|
|
.resolve(resolverFn(container.user.req))
|
||
|
|
.then(function(resolvedPath) {
|
||
|
|
container.proxy.reqBuilder.path = resolvedPath;
|
||
|
|
debug('resolved proxy path:', resolvedPath);
|
||
|
|
return Promise.resolve(container);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = resolveProxyReqPath;
|