Skip to content

Commit

Permalink
ex_tldr: add HTTPoison as an injected dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanhercaz committed Jun 21, 2020
1 parent 740819f commit bd367f7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/ex_tldr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ defmodule ExTldr do
Documentation for ExTldr, an Elixir client for tldr-pages.
"""

@http_client Application.get_env(:ex_tldr, :http_client, HTTPoison)

@doc """
Wrapper for the CLI of the ExTldr client.
"""
Expand Down Expand Up @@ -62,7 +64,7 @@ defmodule ExTldr do
end

defp describe(os, term) do
case HTTPoison.get(process_url(os, term)) do
case @http_client.get(process_url(os, term)) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
IO.puts(body)

Expand All @@ -71,7 +73,7 @@ defmodule ExTldr do
"Term \"#{term}\" not found on \"#{os}\" pages\nExTldr is looking on \"common\" pages."
)

case HTTPoison.get(process_url("common", term)) do
case @http_client.get(process_url("common", term)) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
IO.puts(body)

Expand Down

0 comments on commit bd367f7

Please sign in to comment.