Skip to content

Commit

Permalink
Remove current_request_steps in Req.Request
Browse files Browse the repository at this point in the history
Just use request_steps.
  • Loading branch information
thenrio committed Oct 6, 2023
1 parent 04b12f1 commit b0b1a5d
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/req/request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ defmodule Req.Request do
error_steps: [],
private: %{},
registered_options: MapSet.new(),
current_request_steps: [],
into: nil,
async: nil

Expand Down Expand Up @@ -614,8 +613,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 @@ -632,8 +630,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 @@ -969,12 +966,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 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 @@ -987,7 +982,7 @@ defmodule Req.Request do
end
end

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

0 comments on commit b0b1a5d

Please sign in to comment.