elixir-tesla / tesla

The flexible HTTP client library for Elixir, with support for middleware and multiple adapters.
MIT License
2.01k stars 349 forks source link

Extend a macro-based client with new middleware for runtime usage #596

Closed alizain closed 2 weeks ago

alizain commented 1 year ago

Usage is pretty simple, helps me re-use a compile-time client with some modifications at runtime.

defmodule SomeClient do
    use Tesla

    plug ...
end

# somewhere else
[
    {Tesla.Middleware.BearerAuth, token: 1}
]
|> SomeClient.extend
|> Tesla.get!(...)
yordis commented 1 year ago

Hey there, do you mind adding unit tests to prove the use case and write documentation about it?

alizain commented 1 year ago

@yordis updated, what do you think?

yordis commented 1 year ago

See https://github.com/elixir-tesla/tesla/issues/612