Skip to main content

No project description provided

Project description

Falcon-deps

Dependency injector for Falcon Framework based on taskiq-dependencies.

Installation

Install with pip

pip install falcon-deps

Install with poetry

poetry add falcon-deps

Usage

Start Usage

It's simple as possible.

from falcon_deps import InjectableResource
from falcon.asgi import App, Request, Response
from taskiq_dependencies import Depends


# Imagine we have a database pool.
async def db_pool(
    # Retrieve request object from the actual request.
    request: Request = Depends(),
) -> ConnectionPool:
    return request.context._pool


class Resource(InjectableResource):
    async def on_get(
        self,
        request: Request,
        response: Response,
        # Retrieve database pool as a dependency
        db_pool: ConnctionPool = Depends(db_pool)
    ) -> None:
        ...


app = App()
app.add_route(
    "/test",
    Resource(),
)

Advanced Usage

Falcon gives option to specify suffix for resource. If you want to use suffix with InjectableResource you need to pass suffix to InjectableResource too.

app.add_route(
    "/test",
    Resource(suffix="bob",),
    suffix="bob",
)

If some of methods in Resource don't need dependency injection, it's possible to remove them from injection with exclude_responder_from_inject.

app.add_route(
    "/test",
    Resource(
        exclude_responder_from_inject={
            # Remove on_get and on_post methods from injection.
            "on_get",
            "on_post",
        },
    ),
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

falcon_deps-0.1.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

falcon_deps-0.1.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file falcon_deps-0.1.3.tar.gz.

File metadata

  • Download URL: falcon_deps-0.1.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.9.20 Linux/6.5.0-1025-azure

File hashes

Hashes for falcon_deps-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a258bba6d1ec3c19e941f7361e54e5d6cd49ef85387d388beaad94e7f87a3647
MD5 094c150a90fdfb07c64c17fb0daa175d
BLAKE2b-256 2aca8d828d4f4d45db3009db8229af6b7977dace8d6627b1d3017583b4f3114f

See more details on using hashes here.

File details

Details for the file falcon_deps-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: falcon_deps-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.9.20 Linux/6.5.0-1025-azure

File hashes

Hashes for falcon_deps-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 13af56f6c5d30b4aee068e38621cfa76a313b0e50a7e2025e425034ac68b1164
MD5 56fdfc909a12e17c337163855ff1e884
BLAKE2b-256 f87a530f873fc597a7eeb83d6943eb9a5c89b749f0e9ff85e87569a3bac3f541

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page