Configuration management for Philter proxy library.
Configuration can be set at the application level and overridden per-request.
Application Configuration
config :philter,
finch_name: MyApp.Finch,
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- Name of the Finch pool to use (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)
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
Checks if a content type is eligible for body accumulation.
Returns the configured Finch pool name.
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.
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 }
Functions
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
Returns the configured Finch pool name.
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