Skip to content

Commit d80afb4

Browse files
feat: support setting headers via env
1 parent 47271bd commit d80afb4

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lib/openlayer/client.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,28 @@ def initialize(
6969
)
7070
base_url ||= "https://api.openlayer.com/v1"
7171

72+
headers = {}
73+
custom_headers_env = ENV["OPENLAYER_CUSTOM_HEADERS"]
74+
unless custom_headers_env.nil?
75+
parsed = {}
76+
custom_headers_env.split("\n").each do |line|
77+
colon = line.index(":")
78+
unless colon.nil?
79+
parsed[line[0...colon].strip] = line[(colon + 1)..].strip
80+
end
81+
end
82+
headers = parsed.merge(headers)
83+
end
84+
7285
@api_key = api_key&.to_s
7386

7487
super(
7588
base_url: base_url,
7689
timeout: timeout,
7790
max_retries: max_retries,
7891
initial_retry_delay: initial_retry_delay,
79-
max_retry_delay: max_retry_delay
92+
max_retry_delay: max_retry_delay,
93+
headers: headers
8094
)
8195

8296
@projects = Openlayer::Resources::Projects.new(client: self)

0 commit comments

Comments
 (0)