{"id":23087625,"url":"https://github.com/mkdir700/fastapi-forward","last_synced_at":"2025-04-03T16:45:32.745Z","repository":{"id":265398580,"uuid":"895909916","full_name":"mkdir700/fastapi-forward","owner":"mkdir700","description":"FastAPI Forward is a middleware that enables request forwarding/proxying in FastAPI applications. It allows you to easily forward specific routes to different target URLs while maintaining the original request context.","archived":false,"fork":false,"pushed_at":"2024-11-29T07:33:01.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T05:27:35.191Z","etag":null,"topics":["fastapi","fastapi-forward","forward-proxy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkdir700.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-29T06:57:22.000Z","updated_at":"2024-11-29T07:33:04.000Z","dependencies_parsed_at":"2024-11-29T10:15:58.607Z","dependency_job_id":null,"html_url":"https://github.com/mkdir700/fastapi-forward","commit_stats":null,"previous_names":["mkdir700/fastapi-forward"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkdir700%2Ffastapi-forward","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkdir700%2Ffastapi-forward/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkdir700%2Ffastapi-forward/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkdir700%2Ffastapi-forward/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkdir700","download_url":"https://codeload.github.com/mkdir700/fastapi-forward/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247043196,"owners_count":20874084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","fastapi-forward","forward-proxy"],"created_at":"2024-12-16T19:59:19.761Z","updated_at":"2025-04-03T16:45:32.720Z","avatar_url":"https://github.com/mkdir700.png","language":"Python","readme":"# FastAPI Forward\n\nFastAPI Forward is a middleware that enables request forwarding/proxying in FastAPI applications. It allows you to easily forward specific routes to different target URLs while maintaining the original request context.\n\n## Features\n\n- Simple decorator-based route forwarding\n- Preserves request headers and body\n- Supports conditional forwarding\n- Easy integration with FastAPI applications\n\n## Installation\n\n```bash\npip install fastapi-forward\n```\n\n## Quick Start\n\nHere's a simple example that forwards requests from your FastAPI application to another service:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_forward import forward, init_app\n\napp = FastAPI()\ninit_app(app)\n\n@app.get(\"/\")\n@forward(\"https://api.example.com\")\nasync def root():\n    return {\"message\": \"This response will be replaced by the forwarded response\"}\n```\n\nIn this example, any GET request to \"/\" will be forwarded to \"https://api.example.com/\".\n\n## Usage\n\n### Basic Forwarding\n\nThe most basic usage is to forward a route to another URL:\n\n```python\n@app.get(\"/users\")\n@forward(\"https://api.example.com\")\nasync def get_users():\n    pass\n```\n\nAll requests to \"/users\" will be forwarded to \"https://api.example.com/users\".\n\n### Initialization\n\nMake sure to initialize the middleware before using the forward decorator:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_forward import init_app\n\napp = FastAPI()\ninit_app(app)\n```\n\n### Request Handling\n\nThe middleware:\n- Preserves request headers\n- Forwards request body\n- Maintains HTTP methods\n- Returns the response from the target URL\n\n## Requirements\n\n- Python 3.10\n- FastAPI\n- httpx \u003e= 0.28.0\n\n## Development\n\nTo set up the development environment:\n\n```bash\n# Install PDM if you haven't already\npip install pdm\n\n# Install dependencies\npdm install\n\n# Run tests\npdm run pytest\n```\n\n## License\n\nThis project is licensed under the MIT License.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkdir700%2Ffastapi-forward","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkdir700%2Ffastapi-forward","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkdir700%2Ffastapi-forward/lists"}