Configuration management for Philter proxy library.
Configuration can be set at the application level and overridden per-request.
Application Configuration
config :philter,
receive_timeout: 15_000,
max_payload_size: 1_048_576,
persistable_content_types: ["application/json", "text/xml", "text/*"]Per-Request Overrides
Any option can be overridden when calling Philter.proxy/2:
Philter.proxy(conn,
upstream: "http://api.example.com",
receive_timeout: 30_000,
max_payload_size: 5_242_880
)Options
:finch_name- Deprecated and ignored. The transport uses no connection pool. Still accepted so existing configuration does not crash (default:Philter.Finch):receive_timeout- Timeout in ms for receiving response (default: 15_000):max_payload_size- Max size in bytes for full body accumulation (default: 1_048_576 / 1MB):persistable_content_types- Content types eligible for full body storage (default: see below):log_level- Logger level for lifecycle events, orfalseto disable (default::debug):block_private_networks- Reject upstreams that resolve to private, loopback, link-local or otherwise internal ranges (SSRF egress guard, default:true):allowed_hosts- Hosts that bypass the egress block check entirely. Exact match after downcase + trailing-dot strip (default:[]):dns_timeout- Milliseconds to bound upstream DNS resolution (default: 5_000):connect_timeout- Milliseconds to bound the connection phase to a validated upstream address (default: 5_000):transport_opts- Extra Mint transport options merged into the connection, e.g. a custom CA bundle. Cannot be used to disable TLS certificate verification (default:[])
Default Persistable Content Types
By default, the following content types are eligible for full body accumulation:
application/jsonapplication/xmltext/xmltext/plaintext/html
Wildcards like text/* are supported.
Summary
Functions
Returns the list of hosts that bypass the egress block check.
Returns whether upstreams resolving to internal ranges are blocked.
Returns the connection-phase timeout in milliseconds.
Checks if a content type is eligible for body accumulation.
Returns the DNS resolution timeout in milliseconds.
Returns the configured :finch_name. Deprecated and ignored.
Returns the log level for lifecycle events.
Returns the maximum payload size for full body accumulation in bytes.
Returns the list of content types eligible for full body accumulation.
Returns the receive timeout in milliseconds.
Returns all configuration as a map, with per-request overrides applied.
Returns extra Mint transport options merged into the connection.
Types
@type t() :: %{ finch_name: atom(), receive_timeout: pos_integer(), max_payload_size: pos_integer(), persistable_content_types: [String.t()], log_level: Logger.level() | false, block_private_networks: boolean(), allowed_hosts: [String.t()], dns_timeout: pos_integer(), connect_timeout: pos_integer(), transport_opts: keyword() }
Functions
Returns the list of hosts that bypass the egress block check.
Examples
iex> Philter.Config.allowed_hosts()
[]
iex> Philter.Config.allowed_hosts(allowed_hosts: ["api.internal"])
["api.internal"]
Returns whether upstreams resolving to internal ranges are blocked.
Examples
iex> Philter.Config.block_private_networks()
true
iex> Philter.Config.block_private_networks(block_private_networks: false)
false
@spec connect_timeout(keyword()) :: pos_integer()
Returns the connection-phase timeout in milliseconds.
Examples
iex> Philter.Config.connect_timeout()
5_000
iex> Philter.Config.connect_timeout(connect_timeout: 1_000)
1_000
Checks if a content type is eligible for body accumulation.
Supports exact matches and wildcard patterns (e.g., text/*).
Examples
iex> Philter.Config.content_type_persistable?("application/json", ["application/json", "text/*"])
true
iex> Philter.Config.content_type_persistable?("text/plain", ["application/json", "text/*"])
true
iex> Philter.Config.content_type_persistable?("image/png", ["application/json", "text/*"])
false
@spec dns_timeout(keyword()) :: pos_integer()
Returns the DNS resolution timeout in milliseconds.
Examples
iex> Philter.Config.dns_timeout()
5_000
iex> Philter.Config.dns_timeout(dns_timeout: 1_000)
1_000
Returns the configured :finch_name. Deprecated and ignored.
Examples
iex> Philter.Config.finch_name()
Philter.Finch
iex> Philter.Config.finch_name(finch_name: MyApp.Finch)
MyApp.Finch
@spec log_level(keyword()) :: Logger.level() | false
Returns the log level for lifecycle events.
Set to false to disable all logging. Defaults to :debug.
Examples
iex> Philter.Config.log_level()
:debug
iex> Philter.Config.log_level(log_level: :info)
:info
iex> Philter.Config.log_level(log_level: false)
false
@spec max_payload_size(keyword()) :: pos_integer()
Returns the maximum payload size for full body accumulation in bytes.
Examples
iex> Philter.Config.max_payload_size()
1_048_576
iex> Philter.Config.max_payload_size(max_payload_size: 5_242_880)
5_242_880
Returns the list of content types eligible for full body accumulation.
Supports wildcard patterns like "text/*".
Examples
iex> Philter.Config.persistable_content_types() |> Enum.member?("application/json")
true
iex> Philter.Config.persistable_content_types(persistable_content_types: ["application/json"])
["application/json"]
@spec receive_timeout(keyword()) :: pos_integer()
Returns the receive timeout in milliseconds.
Examples
iex> Philter.Config.receive_timeout()
15_000
iex> Philter.Config.receive_timeout(receive_timeout: 30_000)
30_000
Returns all configuration as a map, with per-request overrides applied.
Useful for getting the full resolved config in one call.
Examples
iex> config = Philter.Config.resolve(receive_timeout: 30_000)
iex> config.receive_timeout
30_000
Returns extra Mint transport options merged into the connection.
Cannot be used to disable TLS certificate verification.
Examples
iex> Philter.Config.transport_opts()
[]
iex> Philter.Config.transport_opts(transport_opts: [cacertfile: "/etc/ssl/cert.pem"])
[cacertfile: "/etc/ssl/cert.pem"]