Skip to content

Commit

Permalink
Asynchronous "getHost" implementation. villadora#284
Browse files Browse the repository at this point in the history
  • Loading branch information
maxstrauch committed Dec 21, 2018
1 parent bf63dbf commit 56c30b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/steps/resolveProxyHost.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
'use strict';
var requestOptions = require('../../lib/requestOptions');

function resolveProxyHost(container) {
async function resolveProxyHost(container) {
var parsedHost;

if (container.options.memoizeHost && container.options.memoizedHost) {
parsedHost = container.options.memoizedHost;
} else {
parsedHost = requestOptions.parseHost(container);
parsedHost = await requestOptions.parseHost(container);
}

container.proxy.reqBuilder.host = parsedHost.host;
container.proxy.reqBuilder.port = container.options.port || parsedHost.port;
container.proxy.requestModule = parsedHost.module;
return Promise.resolve(container);
return container;
}

module.exports = resolveProxyHost;
4 changes: 2 additions & 2 deletions lib/requestOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ function extend(obj, source, skips) {
return obj;
}

function parseHost(Container) {
async function parseHost(Container) {
var host = Container.params.host;
var req = Container.user.req;
var options = Container.options;
host = (typeof host === 'function') ? host(req) : host.toString();
host = (typeof host === 'function') ? (await host(req)) : host.toString();

if (!host) {
return new Error('Empty host parameter');
Expand Down

0 comments on commit 56c30b0

Please sign in to comment.