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

Remove current_request_steps in Req.Request #255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 5 additions & 10 deletions lib/req/request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ defmodule Req.Request do
error_steps: [],
private: %{},
registered_options: MapSet.new(),
current_request_steps: [],
into: nil,
async: nil

Expand Down Expand Up @@ -615,8 +614,7 @@ defmodule Req.Request do
def append_request_steps(request, steps) do
%{
request
| request_steps: request.request_steps ++ steps,
current_request_steps: request.current_request_steps ++ Keyword.keys(steps)
| request_steps: request.request_steps ++ steps
}
end

Expand All @@ -633,8 +631,7 @@ defmodule Req.Request do
def prepend_request_steps(request, steps) do
%{
request
| request_steps: steps ++ request.request_steps,
current_request_steps: Keyword.keys(steps) ++ request.current_request_steps
| request_steps: steps ++ request.request_steps
}
end

Expand Down Expand Up @@ -971,12 +968,10 @@ defmodule Req.Request do
"""
def run_request(request)

def run_request(%{current_request_steps: [step | rest]} = request) do
step = Keyword.fetch!(request.request_steps, step)

def run_request(%{request_steps: [{_name, step} | rest]} = request) do
case run_step(step, request) do
%Req.Request{} = request ->
run_request(%{request | current_request_steps: rest})
run_request(%{request | request_steps: rest})

{%Req.Request{halted: true} = request, response_or_exception} ->
{request, response_or_exception}
Expand All @@ -989,7 +984,7 @@ defmodule Req.Request do
end
end

def run_request(%{current_request_steps: []} = request) do
def run_request(%{request_steps: []} = request) do
case run_step(request.adapter, request) do
{request, %Req.Response{} = response} ->
run_response(request, response)
Expand Down