Skip to content

feat(web)!: compose a web application in WebApplication, with its own interceptors - #346

Open
mofr wants to merge 1 commit into
feat/argument-resolversfrom
feat/interceptors
Open

mofr wants to merge 1 commit into
feat/argument-resolversfrom
feat/interceptors

Conversation

@mofr

@mofr mofr commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #345.

What

  • winter.web.WebApplication(modules, injector, interceptors) replaces winter.application.Application: the code of a web application, its injector and the classes of its interceptors, in the order they run. add(definition) and definitions stay as they were.
  • Interceptors belong to applications. The injector of each request creates them, so their dependencies go to __init__; create_urls checks the arguments of their pre_handle on startup. An instance or a class that is not an Interceptor fails construction.
  • winter.web.interceptor_registry and InterceptorRegistry are gone.
  • winter.application keeps the scan as find_definitions(modules). modules has no default any more: the frame-based "caller directory" broke once the scan is called from inside Winter, and its __main__ special case goes with it.
  • winter.django.create_urls, winter.openapi.generate_openapi, serve_spec and serve_swagger_ui take a WebApplication.

Why

The consumer has three global interceptors. Their order matters in two places and comes from INSTALLED_APPS, and two of them limit themselves to one service's endpoints by matching the path. A per-application ordered list states the order and removes the path filters.

Tests

  • tests/test_application_scope.py: an interceptor of one application does not run in another.
  • tests/web/test_interceptors.py: interceptors run in the given order, with dependencies from the injector.
  • tests/application/test_definitions.py and tests/web/test_web_application.py split the old Application tests.

🤖 Generated with Claude Code

… interceptors

winter.web.WebApplication(modules, injector, interceptors) replaces
winter.application.Application: the code of a web application, its injector
and the classes of its interceptors, in the order they run. The injector of
each request creates the interceptors, so their dependencies go to __init__,
and the URL patterns check their arguments on startup. The process-global
interceptor_registry is gone.

winter.application keeps find_definitions(modules), which WebApplication
uses; modules have no default any more. Adapters and winter.openapi take a
WebApplication.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant