knock-elixir icon indicating copy to clipboard operation
knock-elixir copied to clipboard

Add ability to modify middleware via a configured callback. #14

Open aglassman opened this issue 1 year ago • 1 comments

This allows dynamic configuration of the middleware passed to the Tesla client. If a middleware_callback is configured, the middleware is passed to the callback, and may be modified as needed.

This resolves #14

Usage for open telemetry middleware:

# config.exs
config :my_app, MyApp.KnockImpl,
       api_key: System.get_env("KNOCK_API_PRIVATE_KEY"),
       middleware_callback: &MyApp.Tesla.customize_middleware/1
       
# my_app/tesla.exs
defmodule MyApp.Tesla do

  def customize_middleware(middleware), do: [ Tesla.Middleware.OpenTelemetry | middleware]

end 

aglassman avatar Sep 05 '24 04:09 aglassman

any update about this please?

oliver-kriska avatar Mar 14 '25 08:03 oliver-kriska