     Conn.register_before_send(conn, &log_request(&1, api))
   end
 
-  defp log_request(conn, api) do
+  defp log_request(%Conn{} = conn, api) do
     request = %{
       id: ConnHelpers.get_request_id(conn, nil),
       idempotency_key: ConnHelpers.get_idempotency_key(conn, ""),

      headers: modify_headers_list(conn.req_headers),
      body: Poison.encode!(conn.body_params)
    }
    |> prepare_params
  end

  defp get_response_body(conn) do

    do: nil
  defp get_api_data(%{id: id, name: name, request: request}) do
    %{
      id: id,
      name: name,
      request: Map.take(request, [:scheme, :host, :port, :path, :methods])
    }
  end

