Skip to content

Commit d563eb5

Browse files
feat: support setting headers via env
1 parent d0d32b0 commit d563eb5

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

lib/finch_api/client.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ def initialize(
121121
headers = {
122122
"finch-api-version" => "2020-09-17"
123123
}
124+
custom_headers_env = ENV["FINCH_CUSTOM_HEADERS"]
125+
unless custom_headers_env.nil?
126+
parsed = {}
127+
custom_headers_env.split("\n").each do |line|
128+
colon = line.index(":")
129+
unless colon.nil?
130+
parsed[line[0...colon].strip] = line[(colon + 1)..].strip
131+
end
132+
end
133+
headers = parsed.merge(headers)
134+
end
124135

125136
@client_id = client_id&.to_s
126137
@client_secret = client_secret&.to_s

0 commit comments

Comments
 (0)