Skip to content

Commit 01b4c63

Browse files
feat: support setting headers via env
1 parent 02db7be commit 01b4c63

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lib/lithic/client.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ def initialize(
190190
raise ArgumentError.new("api_key is required, and can be set via environ: \"LITHIC_API_KEY\"")
191191
end
192192

193+
headers = {}
194+
custom_headers_env = ENV["LITHIC_CUSTOM_HEADERS"]
195+
unless custom_headers_env.nil?
196+
parsed = {}
197+
custom_headers_env.split("\n").each do |line|
198+
colon = line.index(":")
199+
unless colon.nil?
200+
parsed[line[0...colon].strip] = line[(colon + 1)..].strip
201+
end
202+
end
203+
headers = parsed.merge(headers)
204+
end
205+
193206
@api_key = api_key.to_s
194207
@webhook_secret = webhook_secret&.to_s
195208

@@ -198,7 +211,8 @@ def initialize(
198211
timeout: timeout,
199212
max_retries: max_retries,
200213
initial_retry_delay: initial_retry_delay,
201-
max_retry_delay: max_retry_delay
214+
max_retry_delay: max_retry_delay,
215+
headers: headers
202216
)
203217

204218
@accounts = Lithic::Resources::Accounts.new(client: self)

0 commit comments

Comments
 (0)