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

prepend_default_steps: Replace captures with MFArgs #16

Closed
wojtekmach opened this issue Jul 1, 2021 · 0 comments · Fixed by #41
Closed

prepend_default_steps: Replace captures with MFArgs #16

wojtekmach opened this issue Jul 1, 2021 · 0 comments · Fixed by #41
Labels
good first issue Good for newcomers

Comments

@wojtekmach
Copy link
Owner

wojtekmach commented Jul 1, 2021

Currently our request struct looks like this:

iex> Req.build(:get, "https://api.github.com") |> Req.prepend_default_steps()
%Req.Request{
  request_steps: [#Function<0.30967734/1 in Req."-fun.normalize_headers/1-">,
   #Function<1.30967734/1 in Req."-fun.default_headers/1-">,
   #Function<2.30967734/1 in Req."-fun.encode/1-">],
  response_steps: [#Function<9.30967734/2 in Req."-fun.follow_redirects/2-">,
   #Function<10.30967734/2 in Req."-fun.decompress/2-">,
   #Function<11.30967734/2 in Req."-fun.decode/2-">],
  ...
}

let's change add_default_steps/2 to use MFArgs so that request, response, and error steps are easier to understand:

%Req.Request{
  request_steps: [
    {Req, :normalize_headers, []},
    {Req, :default_headers, []},
    ...
  ],
  ...
}

we'll of course still continue to support passing anonymous functions.

@wojtekmach wojtekmach added the good first issue Good for newcomers label Jul 13, 2021
@wojtekmach wojtekmach changed the title add_default_steps: Replace captures with MFArgs prepend_default_steps: Replace captures with MFArgs Jul 16, 2021
mhanberg added a commit to mhanberg/req that referenced this issue Sep 12, 2021
This allows for steps to be anonymous functions or an MFA tuple.

Closes wojtekmach#16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant