Skip to content

Commit 52f048f

Browse files
committed
feat: add callback api to WebSocketProxy
- bump `typing_extensions` from `4.5.0` to `4.12.0` - explicitly add `anyio` as a dependency - fix docs `host` typo
1 parent a45086a commit 52f048f

File tree

5 files changed

+260
-36
lines changed

5 files changed

+260
-36
lines changed

mkdocs.yml

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ plugins:
108108
import:
109109
- https://frankie567.github.io/httpx-ws/objects.inv
110110
- https://fastapi.tiangolo.com/objects.inv
111+
- https://anyio.readthedocs.io/en/stable/objects.inv
112+
- https://docs.python.org/3/objects.inv
111113
options:
112114
docstring_style: google
113115
paths: [src]

pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ dependencies = [
5252
"httpx",
5353
"httpx-ws >= 0.4.2",
5454
"starlette",
55-
"typing_extensions >=4.5.0",
55+
"typing_extensions >= 4.12",
56+
"anyio >= 4",
5657
]
5758

5859
[project.optional-dependencies]
@@ -91,13 +92,12 @@ dependencies = [
9192
# NOTE: 👆
9293

9394
# lint-check
94-
"pyright == 1.1.356", # pyright must be installed in the runtime environment
95+
"pyright == 1.1.372", # pyright must be installed in the runtime environment
9596
# test
9697
"pytest == 7.*",
9798
"pytest-cov == 4.*",
9899
"uvicorn[standard] < 1.0.0", # TODO: Once it releases version 1.0.0, we will remove this restriction.
99100
"httpx[http2]", # we don't set version here, instead set it in `[project].dependencies`.
100-
"anyio", # we don't set version here, because fastapi has a dependency on it
101101
"asgi-lifespan==2.*",
102102
"pytest-timeout==2.*",
103103
]

src/fastapi_proxy_lib/core/http.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class BaseHttpProxy(BaseProxyModel):
222222
"""
223223

224224
@override
225-
async def send_request_to_target( # pyright: ignore [reportIncompatibleMethodOverride]
225+
async def send_request_to_target(
226226
self, *, request: StarletteRequest, target_url: httpx.URL
227227
) -> StarletteResponse:
228228
"""Change request headers and send request to target url.
@@ -318,6 +318,8 @@ class ReverseHttpProxy(BaseHttpProxy):
318318
319319
# # Examples
320320
321+
## Basic usage
322+
321323
```python
322324
from contextlib import asynccontextmanager
323325
from typing import AsyncIterator
@@ -341,7 +343,7 @@ async def close_proxy_event(_: FastAPI) -> AsyncIterator[None]: # (1)!
341343
async def _(request: Request, path: str = ""):
342344
return await proxy.proxy(request=request, path=path) # (3)!
343345
344-
# Then run shell: `uvicorn <your.py>:app --host http://127.0.0.1:8000 --port 8000`
346+
# Then run shell: `uvicorn <your_py>:app --host 127.0.0.1 --port 8000`
345347
# visit the app: `http://127.0.0.1:8000/`
346348
# you will get the response from `http://www.example.com/`
347349
```
@@ -452,6 +454,8 @@ class ForwardHttpProxy(BaseHttpProxy):
452454
453455
# # Examples
454456
457+
## Basic usage
458+
455459
```python
456460
from contextlib import asynccontextmanager
457461
from typing import AsyncIterator
@@ -476,7 +480,7 @@ async def close_proxy_event(_: FastAPI) -> AsyncIterator[None]:
476480
async def _(request: Request, path: str = ""):
477481
return await proxy.proxy(request=request, path=path)
478482
479-
# Then run shell: `uvicorn <your.py>:app --host http://127.0.0.1:8000 --port 8000`
483+
# Then run shell: `uvicorn <your_py>:app --host 127.0.0.1 --port 8000`
480484
# visit the app: `http://127.0.0.1:8000/http://www.example.com`
481485
# you will get the response from `http://www.example.com`
482486
```

0 commit comments

Comments
 (0)