Dispatcher

Request routing and dispatch.

Dispatcher - demultiplexes ASGI requests to the mounted apps.

The Dispatcher is the innermost layer of the server’s middleware chain, but it does no routing of its own. It picks the app from the first path segment and relays the whole ASGI call to it; each app owns its middleware chain and routing (handle_request).

Request flow:
scope → first-segment mount → apps[mount] (or apps[“”] fallback)

→ await app(scope, receive, send)

Request creation, route resolution (router.node), handler invocation and response.set_result all happen inside the app, not here.

class genro_asgi.server.dispatcher.Dispatcher(server)[source]

Bases: object

Demultiplex requests to the app that owns the first path segment.

The server no longer routes: each app does its own routing through handle_request. The dispatcher picks the app from the first path segment (falling back to the empty-mount app for anything no app claims) and delegates, wrapping the call in the app’s own middleware chain when one is configured.

server

Parent AsgiServer instance.

__init__(server)[source]

Initialize dispatcher.

Parameters:

server (AsgiServer) – Parent AsgiServer instance.

server