linkd.ext.quart

Extension module adding support for using linkd-based dependency injection with Quart.

See the examples directory for a full working application using this module.

Note

Unlike the FastAPI and Starlette integrations, the default inject() method will work for route handlers when using this extension.


final class Contexts[source]

Collection of the dependency injection context values linkd.ext.quart uses.

REQUEST = 'linkd.contexts.http.request'

DI context used during HTTP request handling.

ROOT = 'linkd.contexts.default'

The root DI context - ALL other contexts are built with this as the parent.

class DiContextMiddleware(app: ASGIApp, manager: DependencyInjectionManager)[source]

Middleware class which handles setting up a DI context for each HTTP request.

Parameters:
  • app – The ASGI app this middleware will be applied to.

  • manager – The dependency injection manager to use when entering the DI context.

Example

import quart
import linkd

manager = linkd.DependencyInjectionManager()

app = quart.Quart(__name__)
app.asgi_app = linkd.ext.quart.DiContextMiddleware(app.asgi_app, manager)