Salemove.HttpClient.Middleware.Proxy (salemove_http_client v6.1.0)

Adds proxy server options to a request if either of the following conditions are met:

  • Environment variable http_proxy (or HTTP_PROXY) is set and requested protocol is http://
  • Environment variable https_proxy (or HTTPS_PROXY) is set and requested protocol is https://

Proxy options are not injected if either of the following conditions are met:

  • Requested host is included into no_proxy (or NO_PROXY) environment variable
  • Http client is configured with option proxy: false

Finch limitation

Tesla.Adapter.Finch (the default adapter) does not support per-request proxy options — Finch configures proxies at pool level. With the Finch adapter this middleware is a no-op: the :proxy option and the proxy environment variables are silently ignored. To proxy requests with Finch, configure the proxy on the pool:

config :salemove_http_client,
  finch_pools: %{
    default: [conn_opts: [proxy: {:http, "proxy.example.com", 3128, []}]]
  }

or use Tesla.Adapter.Hackney for clients that need per-request proxies.

Link to this section Summary

Link to this section Functions

Link to this function

call(env, next, opts)

Callback implementation for Tesla.Middleware.call/3.