Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous "getHost" implementation. #284 #396

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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