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

middleware example: print out both headers and options #535

Merged
merged 3 commits into from Jun 23, 2022
Merged

middleware example: print out both headers and options #535

merged 3 commits into from Jun 23, 2022

Conversation

JLarky
Copy link
Contributor

@JLarky JLarky commented Jun 23, 2022

I was looking at https://hexdocs.pm/tesla/Tesla.Middleware.html docs that were for 1.4.4 and noticed that the middleware example doesn't work. I wanted to fix it, but noticed that here on GitHub this code is already updated, but it still has some issues. I can imagine that originally it was indeed intended to use middleware options as options for IO.inspect/2 but I am more inclined to believe that options were passed to IO.inspect just so the compiler wouldn't complain about the unused variable :) so I think it would be better to either print the options out or just remove them completely and replace them with _options.

p.s. the first time I'm contributing to this project. So I will use this opportunity to say that your library is very cool and I'm happy using it :)

this code will most likely crash if you put anything in your options, so I decided to print options as well
@teamon
Copy link
Member

teamon commented Jun 23, 2022

Good catch!

For the sake of simplicity I think we should go with:

def call(env, next, _opts) do
  IO.inspect(env.headers)

@yordis yordis merged commit 308a676 into elixir-tesla:master Jun 23, 2022
@yordis
Copy link
Member

yordis commented Jun 23, 2022

🚀

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.

None yet

3 participants