TeslaDumper

This package allows to dump Tesla requests to curl. It can be produced in two middlewares:

  1. plug(TeslaDumper) adds simple curl command to Tesla.Env
  2. plug(TeslaDumpLogger) just logs the curl command with Info level.

If you want to change the behavior of logging - Just create your own logger(using TeslaDumpLogger as example) and process curl command.

Installation

If available in Hex, the package can be installed by adding tesla_dumper to your list of dependencies in mix.exs:

def deps do
  [
    {:tesla_dumper, "~> 0.1.0"}
  ]
end

Then you can middlewares to Tesla Client:

defmodule DummyGithubClient do
  use Tesla

  plug(Tesla.Middleware.Headers, [{"authorization", "token xyz"}])
  plug(Tesla.Middleware.JSON)
  plug(TeslaDumper)

  def user_repos(url, login) do
    get(url <> "/" <> login)
  end
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/tesla_dumper.