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

Add Client.update_middleware/2 function #523

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maciej-szlosarczyk
Copy link

I have seen this being a pain point a few times so maybe it's useful for someone else.

A typical use-case is the following:

A third-party library (i.e GitHub) exposes a function that returns a Tesla client, but I want to append a header or add logging/telemetry to it. Currently I need to write a wrapper for Tesla.Client.middleware/1 and Tesla.client/2, this merges the two into a single function.

A typical use-case is the following:

A third-party library (i.e GitHub) exposes a function that returns a
Tesla client, but I want to append a header or add logging/telemetry
to it. I need to write a wrapper for Tesla.Client.middleware/1 and
Tesla.client/2.
@teamon
Copy link
Member

teamon commented May 8, 2022

👋

I've found similar need when working on the OpenAPI generator and I've ended up with https://github.com/elixir-tesla/tesla/blob/openapi/lib/tesla/client.ex#L51-L72 (this code lives only in the openapi branch, nowhere near to be released yet)

Do you see the need for generic update_middleware or would insert be enough?

@maciej-szlosarczyk
Copy link
Author

Hey @teamon, for my use-case insert would work as well. Let me know if I should extract it from that branch and rework this PR with that or help in any other way.

@yordis yordis force-pushed the master branch 6 times, most recently from 2bca420 to fe7207c Compare October 24, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants