Skip to content
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

Merged
merged 4 commits into from
Oct 13, 2019
Merged

Fix Tesla middlewares #39

merged 4 commits into from
Oct 13, 2019

Conversation

Ironjanowar
Copy link
Collaborator

@Ironjanowar Ironjanowar commented Oct 12, 2019

This tries to fix #36

Copy link
Owner

@rockneurotiko rockneurotiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments 👀

end
end

defp format_middleware({_, _} = mf), do: mf
Copy link
Owner

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?

defp format_middleware(_), do: :error

defp custom_middlewares() do
(Application.get_env(:ex_gram, __MODULE__, [])[:middlewares] || [])
Copy link
Owner

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

|> Enum.reduce([], fn elem, acc ->
case format_middleware(elem) do
{:ok, middleware} ->
IO.inspect(middleware)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Collaborator Author

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]
Copy link
Owner

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

[middleware | acc]

:error ->
Logger.debug("Discarded, element is not a middleware: #{inspect(elem)}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a warn?

Copy link
Owner

@rockneurotiko rockneurotiko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rockneurotiko rockneurotiko merged commit 63f3b6d into master Oct 13, 2019
@rockneurotiko rockneurotiko deleted the tesla_middlewares_fix branch October 13, 2019 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tesla-Middlewares] Can not write functions in config
2 participants