rewire-fastapi


Namerewire-fastapi JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryFastapi integration for rewire
upload_time2024-08-29 06:50:34
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2024 rewirepy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# rewire\_fastapi

A FastAPI integration for rewire.

## Installation

To get started, install `rewire_fastapi` using pip:

```bash
pip install rewire_fastapi
```

## Supported Servers

This package supports running with both Uvicorn and Hypercorn servers (`rewire_fastapi.server`).

## Usage

First, import add `rewire_fastapi` to your rewire application:

```python
# ...
import rewire_fastapi

async def main():
    async with Space().init().use():
        DependenciesModule.get().add(rewire_fastapi.plugin)  # add this
        # ...

```

Then have injected fastapi in your files:

```python
from fastapi import APIRouter, FastAPI
from rewire.plugins import simple_plugin

plugin = simple_plugin()
router = APIRouter()


@router.get("/hello")
def hello_world():
    return "world"


@plugin.setup()
async def include_router(app: FastAPI):
    app.include_router(router)
```

## Configuration

Configure the package in `config.yaml` file:

```yaml
rewire_fastapi:
  server: "hypercorn"
  app: # will be passed to FastAPI instance
    title: "My App"
  uvicorn: # (optional)
    port: 1234
  hypercorn: # (optional)
    bind: "0.0.0.0:1234"
  routes:  # (optional)
    tag_prefix: "myapp:"
  patch: # (optional)
    swagger_hierarchical_tags: true
    tag_prefixes: true
  middleware:
    cors: # enable cors middleware (optional)
      allow_origins: ["*"]
      allow_methods: ["*"]
      allow_headers: ["*"]

```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rewire-fastapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Ivan Vozhakov <gou177@bk.ru>",
    "download_url": "https://files.pythonhosted.org/packages/cd/08/b51a0bf5334eb7de04c4b182a9bd74c559cd52da9bca47c7b2a11136f871/rewire_fastapi-0.2.0.tar.gz",
    "platform": null,
    "description": "\r\n# rewire\\_fastapi\r\n\r\nA FastAPI integration for rewire.\r\n\r\n## Installation\r\n\r\nTo get started, install `rewire_fastapi` using pip:\r\n\r\n```bash\r\npip install rewire_fastapi\r\n```\r\n\r\n## Supported Servers\r\n\r\nThis package supports running with both Uvicorn and Hypercorn servers (`rewire_fastapi.server`).\r\n\r\n## Usage\r\n\r\nFirst, import add `rewire_fastapi` to your rewire application:\r\n\r\n```python\r\n# ...\r\nimport rewire_fastapi\r\n\r\nasync def main():\r\n    async with Space().init().use():\r\n        DependenciesModule.get().add(rewire_fastapi.plugin)  # add this\r\n        # ...\r\n\r\n```\r\n\r\nThen have injected fastapi in your files:\r\n\r\n```python\r\nfrom fastapi import APIRouter, FastAPI\r\nfrom rewire.plugins import simple_plugin\r\n\r\nplugin = simple_plugin()\r\nrouter = APIRouter()\r\n\r\n\r\n@router.get(\"/hello\")\r\ndef hello_world():\r\n    return \"world\"\r\n\r\n\r\n@plugin.setup()\r\nasync def include_router(app: FastAPI):\r\n    app.include_router(router)\r\n```\r\n\r\n## Configuration\r\n\r\nConfigure the package in `config.yaml` file:\r\n\r\n```yaml\r\nrewire_fastapi:\r\n  server: \"hypercorn\"\r\n  app: # will be passed to FastAPI instance\r\n    title: \"My App\"\r\n  uvicorn: # (optional)\r\n    port: 1234\r\n  hypercorn: # (optional)\r\n    bind: \"0.0.0.0:1234\"\r\n  routes:  # (optional)\r\n    tag_prefix: \"myapp:\"\r\n  patch: # (optional)\r\n    swagger_hierarchical_tags: true\r\n    tag_prefixes: true\r\n  middleware:\r\n    cors: # enable cors middleware (optional)\r\n      allow_origins: [\"*\"]\r\n      allow_methods: [\"*\"]\r\n      allow_headers: [\"*\"]\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 rewirepy  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Fastapi integration for rewire",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/rewirepy/rewire-fastapi"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3e288b198858f9487cbe816767a2ffe5b3417e48cf28710848bd528d50069ee",
                "md5": "5616cec37c0722233701ba8d5e5d9f26",
                "sha256": "c6c7cd18dcd60bcf4938b341dd93beee92b0e8b976a07aea1f54329cbfbfa19b"
            },
            "downloads": -1,
            "filename": "rewire_fastapi-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5616cec37c0722233701ba8d5e5d9f26",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 7632,
            "upload_time": "2024-08-29T06:50:29",
            "upload_time_iso_8601": "2024-08-29T06:50:29.584430Z",
            "url": "https://files.pythonhosted.org/packages/b3/e2/88b198858f9487cbe816767a2ffe5b3417e48cf28710848bd528d50069ee/rewire_fastapi-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd08b51a0bf5334eb7de04c4b182a9bd74c559cd52da9bca47c7b2a11136f871",
                "md5": "308fe5d397366f4f7efcde9529d92da1",
                "sha256": "3b338d9e35318d788f1fb62a89b71742c116041a2b2247e7c49d228817bc5c60"
            },
            "downloads": -1,
            "filename": "rewire_fastapi-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "308fe5d397366f4f7efcde9529d92da1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 6296,
            "upload_time": "2024-08-29T06:50:34",
            "upload_time_iso_8601": "2024-08-29T06:50:34.212252Z",
            "url": "https://files.pythonhosted.org/packages/cd/08/b51a0bf5334eb7de04c4b182a9bd74c559cd52da9bca47c7b2a11136f871/rewire_fastapi-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-29 06:50:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rewirepy",
    "github_project": "rewire-fastapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "rewire-fastapi"
}
        
Elapsed time: 0.86539s