asphalt.web.litestar

class asphalt.web.litestar.AsphaltProvide(cls, name='default')

Bases: object

Asphalt’s version of Litestar’s Provide().

This should be marked as the default value on a parameter that should receive an Asphalt resource.

Parameters:
  • cls (type) – the type of the resource

  • name (str) – the name of the resource within its unique type

class asphalt.web.litestar.LitestarComponent(components=None, *, host='127.0.0.1', port=8000, route_handlers=(), middlewares=(), config=None)

Bases: ASGIComponent[Litestar]

A component that serves a Litestar application.

Parameters:
  • host – the IP address to bind to

  • port – the port to bind to

  • route_handlers – list of callables or module:varname references that point to the routers / controolers / handlers that should be attached to the application

  • middlewares – list of callables or dicts to be added as middleware using add_middleware()

Note

The following options are preset here:

  • debug: set to the value of __debug__; unless overridden

  • logging_config: always set to None, as Asphalt handles logging configuration

If you supply the a pre-made application object that has route handlers already in it, know that any middleware added to it during the initialization of LitestarComponent will NOT apply to the route handlers previously added to the application