Skip to content

Commit

Permalink
handle HTTPoison headers as lists instead of maps
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Weiss committed Apr 6, 2016
1 parent 74677e9 commit 6ff44fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/_build
/cover
/deps
/doc
erl_crash.dump
*.ez
.mix_tasks
5 changes: 2 additions & 3 deletions lib/forcex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ defmodule Forcex do
###

def start(initial_state \\ %{}) do
HTTPoison.start
GenServer.start __MODULE__, initial_state
end

Expand Down Expand Up @@ -271,7 +270,7 @@ defmodule Forcex do

defp authenticated_get(url = <<"http"::utf8, _::binary>>, {token, token_type}) do
url
|> HTTPoison.get!(%{"Authorization" => (token_type <> " " <> token)})
|> HTTPoison.get!([{"Authorization", (token_type <> " " <> token)}])
|> parse_payload
end
defp authenticated_get(object, params, state = %{instance_url: url, access_token: token, token_type: token_type}) do
Expand All @@ -283,7 +282,7 @@ defmodule Forcex do
|> authenticated_get({token, token_type})
end

defp parse_payload(%{body: body, headers: %{"Content-Type" => <<"application/json"::utf8, _::binary>>}}) do
defp parse_payload(%{body: body, headers: _headers}) do
body
|> JSX.decode!
end
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Forcex.Mixfile do
def project do
[
app: :forcex,
version: "0.2.0",
version: "0.2.1",
elixir: "~> 1.0",
name: "Forcex",
description: @description,
Expand Down Expand Up @@ -44,7 +44,7 @@ defmodule Forcex.Mixfile do
# Type `mix help deps` for more examples and options
defp deps do
[
{:httpoison, "~> 0.5"},
{:httpoison, "~> 0.8"},
{:exjsx, "~> 3.1"},
{:timex, "~> 2.0"},
{:excoveralls, "~> 0.5", only: :test},
Expand Down

0 comments on commit 6ff44fa

Please sign in to comment.