-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Tesla middlewares #39
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments 👀
lib/ex_gram/adapter/tesla.ex
Outdated
end | ||
end | ||
|
||
defp format_middleware({_, _} = mf), do: mf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return {:ok, mf}
right?
lib/ex_gram/adapter/tesla.ex
Outdated
defp format_middleware(_), do: :error | ||
|
||
defp custom_middlewares() do | ||
(Application.get_env(:ex_gram, __MODULE__, [])[:middlewares] || []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save this to a variable, I think having parenthesis before a pipe doesn't look good
lib/ex_gram/adapter/tesla.ex
Outdated
|> Enum.reduce([], fn elem, acc -> | ||
case format_middleware(elem) do | ||
{:ok, middleware} -> | ||
IO.inspect(middleware) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe
case format_middleware(elem) do | ||
{:ok, middleware} -> | ||
IO.inspect(middleware) | ||
[middleware | acc] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful, this will return the middlewares reversed as how it was defined in the config, and the order is important in middlewares
lib/ex_gram/adapter/tesla.ex
Outdated
[middleware | acc] | ||
|
||
:error -> | ||
Logger.debug("Discarded, element is not a middleware: #{inspect(elem)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not a warn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This tries to fix #36