Source code for genro_asgi.config.configuration_handler

# Copyright 2025 Softwell S.r.l.
# Licensed under the Apache License, Version 2.0

"""ConfigurationHandler — owns the configuration builder and renders it.

The server owns one ConfigurationHandler. It mounts the user's
ServerConfiguration builder and renders it toward the server: the render
target is the server itself (never the handler), and the server carries the
methods that turn the configuration nodes into server state.

The handler is the place where the reactive runtime will live (Fase 2):
a ``live()`` section mutating the configuration will re-render the touched
nodes toward the same target, the server, applying changes incrementally.
"""

from __future__ import annotations

from typing import Any

from genro_builders.builder import BuilderHandler


[docs] class ConfigurationHandler(BuilderHandler): """Owns the ServerConfiguration builder; renders it onto the server.""" def __init__(self, server: Any, application: Any = None) -> None: super().__init__(application=application) self.server = server
[docs] def configure(self, builder: Any) -> None: """Mount the configuration builder and render it onto the server. ``add_builder`` runs the recipe (setup + main); the render delivers the configuration nodes to the server, which applies them. """ self.add_builder(builder) builder.render(mode="asgi", target=self.server)
if __name__ == "__main__": pass