Skip to content

Commit

Permalink
add Tesla.put_opt(key,value) helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
teamon committed Sep 9, 2016
1 parent b87a875 commit 558743f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/tesla.ex
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ defmodule Tesla do
def run(env, [{m,f} | rest]), do: apply(m, f, [env, rest])
def run(env, [{m,f,a} | rest]), do: apply(m, f, [env, rest | a])

# useful helper fuctions
def put_opt(env, key, value) do
Map.update!(env, :opts, &Keyword.put(&1, key, value))
end


def default_adapter do
adapter = Application.get_env(:tesla, :adapter, :httpc) |> Tesla.alias
{adapter, []}
Expand Down
2 changes: 1 addition & 1 deletion lib/tesla/middleware/core.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ defmodule Tesla.Middleware.DecodeRels do

def parse_rels(env) do
if link = env.headers["link"] do
Map.update!(env, :opts, &Keyword.put(&1, :rels, rels(link)))
Tesla.put_opt(env, :rels, rels(link))
else
env
end
Expand Down

0 comments on commit 558743f

Please sign in to comment.