Skip to content

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