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
@@ -83,6 +87,15 @@ def __init__(
8387 if base_url is None :
8488 base_url = f"https://api-v2.nept.finance"
8589
90+ custom_headers_env = os .environ .get ("NEPTUNE_API_V2_CUSTOM_HEADERS" )
91+ if custom_headers_env is not None :
92+ parsed : dict [str , str ] = {}
93+ for line in custom_headers_env .split ("\n " ):
94+ colon = line .find (":" )
95+ if colon >= 0 :
96+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
97+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
98+
8699 super ().__init__ (
87100 version = __version__ ,
88101 base_url = base_url ,
@@ -272,6 +285,15 @@ def __init__(
272285 if base_url is None :
273286 base_url = f"https://api-v2.nept.finance"
274287
288+ custom_headers_env = os .environ .get ("NEPTUNE_API_V2_CUSTOM_HEADERS" )
289+ if custom_headers_env is not None :
290+ parsed : dict [str , str ] = {}
291+ for line in custom_headers_env .split ("\n " ):
292+ colon = line .find (":" )
293+ if colon >= 0 :
294+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
295+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
296+
275297 super ().__init__ (
276298 version = __version__ ,
277299 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments