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

support httpc profile through adapter configs #36

Merged
merged 1 commit into from
Aug 23, 2018

Conversation

tsloughter
Copy link
Contributor

No description provided.


%%====================================================================
%% API functions
%%====================================================================

request(Method, URI, ReqHeaders, Body) ->
request(Method, URI, ReqHeaders, Body, Options) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: could you rename Options to AdapterConfig here and elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, will do.

src/hex_http.erl Outdated
@@ -9,8 +9,9 @@
-type status() :: non_neg_integer().
-type headers() :: #{binary() => binary()}.
-type body() :: nil.
-type adapter_config() :: maps:map().
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity, is there a difference between map() and maps:map()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Na. maps:map() probably is just -type map() :: maps()..

Copy link
Member

@wojtekmach wojtekmach Aug 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually looks like there's no such type, let's go with just map() :)

iex> t :maps
@opaque iterator()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh weird... ok, fixing up.

Copy link
Member

@ericmj ericmj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💜

@ericmj
Copy link
Member

ericmj commented Aug 23, 2018

I wonder if we should document how to set up a profile with proxy settings? I would guess most using hex_core would want this.

@ferd
Copy link
Contributor

ferd commented Aug 23, 2018

Yeah it wouldn't necessarily be very hard, rebar3 does it in probably ~50 lines of code.

The values are parsed off the env with: https://github.com/erlang/rebar3/blob/416176290b20e1e68c5901f83cccef71ec2bc322/src/rebar_utils.erl#L840-L867

The values are set and get with https://github.com/erlang/rebar3/blob/416176290b20e1e68c5901f83cccef71ec2bc322/src/rebar_utils.erl#L910-L922

And used at the call-site as: https://github.com/erlang/rebar3/blob/416176290b20e1e68c5901f83cccef71ec2bc322/src/rebar_pkg_resource.erl#L128-L133

There's some additional complexity by using a rebar specific profile for values, which prevents funny interactions with users of rebar3 shell and test frameworks if they end up using httpc as well.

@wojtekmach wojtekmach merged commit 0f07a94 into hexpm:master Aug 23, 2018
@wojtekmach
Copy link
Member

Thank you!

Good idea about updating docs with a howto, we can work on that separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants