File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 RequestOptions ,
2020 not_given ,
2121)
22- from ._utils import is_given , get_async_library
22+ from ._utils import (
23+ is_given ,
24+ is_mapping_t ,
25+ get_async_library ,
26+ )
2327from ._compat import cached_property
2428from ._version import __version__
2529from ._streaming import Stream as Stream , AsyncStream as AsyncStream
@@ -126,6 +130,15 @@ def __init__(
126130 if base_url is None :
127131 base_url = f"https://control.knock.app"
128132
133+ custom_headers_env = os .environ .get ("KNOCK_MGMT_CUSTOM_HEADERS" )
134+ if custom_headers_env is not None :
135+ parsed : dict [str , str ] = {}
136+ for line in custom_headers_env .split ("\n " ):
137+ colon = line .find (":" )
138+ if colon >= 0 :
139+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
140+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
141+
129142 super ().__init__ (
130143 version = __version__ ,
131144 base_url = base_url ,
@@ -419,6 +432,15 @@ def __init__(
419432 if base_url is None :
420433 base_url = f"https://control.knock.app"
421434
435+ custom_headers_env = os .environ .get ("KNOCK_MGMT_CUSTOM_HEADERS" )
436+ if custom_headers_env is not None :
437+ parsed : dict [str , str ] = {}
438+ for line in custom_headers_env .split ("\n " ):
439+ colon = line .find (":" )
440+ if colon >= 0 :
441+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
442+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
443+
422444 super ().__init__ (
423445 version = __version__ ,
424446 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments