Skip to content

Commit 8629f6f

Browse files
feat: Proxy support (#508)
1 parent 2ca2e46 commit 8629f6f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

postgrest/_async/client.py

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(
2929
headers: Dict[str, str] = DEFAULT_POSTGREST_CLIENT_HEADERS,
3030
timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT,
3131
verify: bool = True,
32+
proxy: Optional[str] = None,
3233
) -> None:
3334
BasePostgrestClient.__init__(
3435
self,
@@ -37,6 +38,7 @@ def __init__(
3738
headers=headers,
3839
timeout=timeout,
3940
verify=verify,
41+
proxy=proxy,
4042
)
4143
self.session = cast(AsyncClient, self.session)
4244

@@ -46,12 +48,14 @@ def create_session(
4648
headers: Dict[str, str],
4749
timeout: Union[int, float, Timeout],
4850
verify: bool = True,
51+
proxy: Optional[str] = None,
4952
) -> AsyncClient:
5053
return AsyncClient(
5154
base_url=base_url,
5255
headers=headers,
5356
timeout=timeout,
5457
verify=verify,
58+
proxy=proxy,
5559
follow_redirects=True,
5660
http2=True,
5761
)

postgrest/_sync/client.py

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(
2929
headers: Dict[str, str] = DEFAULT_POSTGREST_CLIENT_HEADERS,
3030
timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT,
3131
verify: bool = True,
32+
proxy: Optional[str] = None,
3233
) -> None:
3334
BasePostgrestClient.__init__(
3435
self,
@@ -37,6 +38,7 @@ def __init__(
3738
headers=headers,
3839
timeout=timeout,
3940
verify=verify,
41+
proxy=proxy,
4042
)
4143
self.session = cast(SyncClient, self.session)
4244

@@ -46,12 +48,14 @@ def create_session(
4648
headers: Dict[str, str],
4749
timeout: Union[int, float, Timeout],
4850
verify: bool = True,
51+
proxy: Optional[str] = None,
4952
) -> SyncClient:
5053
return SyncClient(
5154
base_url=base_url,
5255
headers=headers,
5356
timeout=timeout,
5457
verify=verify,
58+
proxy=proxy,
5559
follow_redirects=True,
5660
http2=True,
5761
)

postgrest/base_client.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ def __init__(
1919
headers: Dict[str, str],
2020
timeout: Union[int, float, Timeout],
2121
verify: bool = True,
22+
proxy: Optional[str] = None,
2223
) -> None:
2324
headers = {
2425
**headers,
2526
"Accept-Profile": schema,
2627
"Content-Profile": schema,
2728
}
28-
self.session = self.create_session(base_url, headers, timeout, verify)
29+
self.session = self.create_session(base_url, headers, timeout, verify, proxy)
2930

3031
@abstractmethod
3132
def create_session(
@@ -34,6 +35,7 @@ def create_session(
3435
headers: Dict[str, str],
3536
timeout: Union[int, float, Timeout],
3637
verify: bool = True,
38+
proxy: Optional[str] = None,
3739
) -> Union[SyncClient, AsyncClient]:
3840
raise NotImplementedError()
3941

0 commit comments

Comments
 (0)