httk.serve.composition

Compose caller-owned Starlette applications at explicit URL paths.

Classes

ASGIAppMount

Associate a Starlette application with an explicit absolute path.

Functions

compose_asgi_apps(mounts, *[, root])

Compose Starlette applications at caller-selected URL paths.

Module Contents

class httk.serve.composition.ASGIAppMount[source]

Associate a Starlette application with an explicit absolute path.

Parameters:
  • path – Canonical absolute URL path, with / reserved for a root fallback.

  • app – Starlette application to mount.

The composed application owns the mounted applications for the duration of its lifespan and enters each distinct child’s Starlette lifespan once. Constructing a mount or a composition does not close or otherwise mutate caller-owned applications when validation fails.

path: str[source]
app: starlette.applications.Starlette[source]
httk.serve.composition.compose_asgi_apps(mounts, *, root=None)[source]

Compose Starlette applications at caller-selected URL paths.

More-specific paths are routed before their ancestors regardless of caller order. At application startup, each distinct mounted child is entered in that deterministic route order and is exited in reverse order; a failed startup unwinds children that already started. The returned parent owns lifespan coordination but not application configuration or data.

Parameters:
Returns:

Parent Starlette application containing the requested mounts.

Raises:
  • TypeError – If a descriptor or application has the wrong type.

  • ValueError – If paths are malformed, noncanonical, or duplicated.

Return type:

starlette.applications.Starlette