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

Add support for the `baseUrl` option #86

Merged
merged 1 commit into from Jun 19, 2015
Merged

Add support for the `baseUrl` option #86

merged 1 commit into from Jun 19, 2015

Conversation

@jmonster
Copy link
Contributor

jmonster commented May 21, 2015

README.changes

// all attributes are optional
var options = {
    baseUrl:   fully qualified uri string used as the base url. Most useful with `request.defaults`, for example when you want to do many requests to the same domain.  If `baseUrl` is `https://example.com/api/`, then requesting `/end/point?test=true` will fetch `https://example.com/api/end/point?test=true`. When `baseUrl` is given, `uri` must also be a string.
    payload:   readableStream || 'foo=bar' || new Buffer('foo=bar'),
    /* ... */
};

Example

Wreck.request(method, '/apps', { baseUrl: 'https://api.heroku.com' }, optionalCallback);

Example [built ontop of #85]

const apiClient = Wreck.defaults({
  baseUrl: `https://api.heroku.com/`,
  headers: {
    'x-foo-bar': 12345
  }
});

var f = apiClient('/apps', function(err,body) {
    expect(f._headers.host).to.equal('api.heroku.com');
    expect(f._headers['x-foo-bar']).to.equal(12345);
});
@jmonster jmonster force-pushed the jmonster:base-url branch from f217d87 to 0e8bb72 May 21, 2015
@hueniverse hueniverse added the feature label May 29, 2015
@jmonster jmonster force-pushed the jmonster:base-url branch from 0e8bb72 to 3b8cb97 Jun 12, 2015
@jmonster jmonster force-pushed the jmonster:base-url branch from 3b8cb97 to 837d5dd Jun 12, 2015
@jmonster

This comment has been minimized.

Copy link
Contributor Author

jmonster commented Jun 12, 2015

Updated to pass tests.

Is there any interest in this feature? :)

@geek geek added this to the 5.6.0 milestone Jun 19, 2015
@geek geek self-assigned this Jun 19, 2015
geek added a commit that referenced this pull request Jun 19, 2015
Add support for `baseUrl` option
@geek geek merged commit ba4003d into hapijs:master Jun 19, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@geek geek changed the title add support for the `baseUrl` option Add support for the `baseUrl` option Jun 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.