Skip to main content

A plugin for Litestar to integrate `svcs`.

Project description

Litestar Svcs

A plugin to integrate litestar with svcs.

Basic Usage

from litestar import Litestar
from litestar import get
from litestar_svcs import SvcsPlugin, SvcsPluginConfig

from svcs import Container, Registry

@get("/", sync_to_thread=False)
def get_user(svcs_container: Container) -> int:
  return svcs_container.get(int)


registry = Registry()
registry.register_factory(int, lambda: 10)

svcs_plugin_config = SvcsPluginConfig(registry=registry)
svcs_plugin = SvcsPlugin(svcs_plugin_config)

app = Litestar([get_user], plugins=[svcs_plugin])

Configuring

  • You can pass in the registry instance, as in the example, to the config or you can give it a callable (sync or async) and it will be used to create the registry when the app is starting.

  • You can give a custom name to the name of the kwarg for injecting the containers by setting a different value for container_dependency_key (default is svcs_container).

    NOTE: You cannot configure the name of the kwarg which injects the registry (the kwarg name is svcs_registry).

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

litestar_svcs-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

litestar_svcs-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file litestar_svcs-0.1.1.tar.gz.

File metadata

  • Download URL: litestar_svcs-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for litestar_svcs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ece61044daf29f3d88c27e7baab2bc3e19021191aa55d37a62d6a176b337854e
MD5 7c159bf2d5c19db22d123cbf1abb9e95
BLAKE2b-256 927ad85846dada648fc49d9ba6c59d2f19fd2f5fc95b40bc7dc92d60db00047a

See more details on using hashes here.

File details

Details for the file litestar_svcs-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for litestar_svcs-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f8610db38353129fd3bf30dc293eecb2584ccef2cedf231fc80aa16661dfc079
MD5 6a9be4b25139564471579b0abcdad775
BLAKE2b-256 0263fb822ed3a785dc107a315d8f48dd97162b391ac218d38257087946adfaff

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