WSH032 / fastapi-proxy-lib

HTTP/WebSocket proxy for starlette/FastAPI
https://wsh032.github.io/fastapi-proxy-lib/
Apache License 2.0
25 stars 4 forks source link
asgi fastapi forward-proxy gateway http httpx httpx-ws proxy reverse-proxy starlette websocket

FastAPI Proxy Lib

HTTP/WebSocket proxy for starlette/FastAPI

CI/CD CI: lint-test pre-commit.ci status
CI: docs CI: publish
Code codecov Code style: black Ruff Checked with pyright
Package PyPI - Version PyPI - Downloads PyPI - Python Version
Meta Hatch project GitHub License

Documentation: https://wsh032.github.io/fastapi-proxy-lib/

Source Code: https://github.com/WSH032/fastapi-proxy-lib/


Features

other features

FastAPI Proxy Lib stands on the shoulders of giants

So, it perfectly supports all features of httpx.AsyncClient, you can even use your custom AsyncClient, Transport.

See Advanced Usage for more details.

except cookies and base_url arguments, which are taken over by fastapi-proxy-lib

Installation

!!! note

We follow semantic versioning.<br>
This is a young project, and before 1.0.0, there may be changes in the API (we try to avoid that).<br>
We will release security updates at any time, please try to keep the version updated, instead of pinning to the old version.<br>
pin to `major version` is recommended.<br>
visit our `CHANGELOG.md` for more info.
pip install fastapi-proxy-lib[standard]

Perhaps you've noticed that we're installing fastapi-proxy-lib[standard] instead of fastapi-proxy-lib. The difference is:

If you only need to use this library with Starlette, you only need to install the latter.

Quick start

With the helper functions, get the FastAPI proxy server app is very convenient and out of the box:

from fastapi_proxy_lib.fastapi.app import reverse_http_app

app = reverse_http_app(base_url="http://www.example.com/foo/")

That's all! Now, you can launch the proxy server with uvicorn:

uvicorn main:app  --host 127.0.0.1 --port 8000

Then, visit http://127.0.0.1:8000/bar?baz=1, you will get the response from http://www.example.com/foo/bar?baz=1.

Continue, please visit to our documentation 📚 for more details:

development

English is not the native language of the author (me), so if you find any areas for improvement in the documentation, your feedback is welcome.

If you think this project helpful, consider giving it a star GitHub Repo stars, which makes me happy. :smile:

Refers

Can fastapi proxy another site as a response to the request?

License

This project is licensed under the terms of the Apache License 2.0.