Packages

Harpoon is an http client framework built on top of Tesla that produces clients that are pluggable, behave predictibly, and can easily be mocked.

Current section

Files

Jump to
harpoon lib example.ex
Raw

lib/example.ex

defmodule Harpoon.Example do
use Harpoon
# import Fisherman
plug(Harpoon.Response)
plug(Tesla.Middleware.BaseUrl, "https://jsonplaceholder.typicode.com/")
plug(Tesla.Middleware.JSON)
def todos() do
get(client(), "/todos")
end
end
defmodule Harpoon.Example.Override do
require Logger
def todos() do
{:ok,
[
%{
"completed" => false,
"id" => 1,
"title" => "delectus aut autem",
"userId" => 1
},
%{
"completed" => true,
"id" => 2,
"title" => "quis ut nam facilis et officia qui",
"userId" => 1
}
]}
end
def harpoon_catch(fun, args) do
Logger.info(inspect({fun, args}))
end
end