Skip to content

feat(web)!: resolve arguments from the request or the application's injector - #345

Open
mofr wants to merge 1 commit into
feat/exception-handlersfrom
feat/argument-resolvers
Open

mofr wants to merge 1 commit into
feat/exception-handlersfrom
feat/argument-resolvers

Conversation

@mofr

@mofr mofr commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #344.

What

  • An argument of an API method, an interceptor's pre_handle or an exception handler is either mapped from the request by Winter's fixed resolvers (path, query, @query_parameters, @request_body, @request_header, ResponseHeader[T], PagePosition) or taken from the injector of the request.
  • The injector of a request is a child of the application's injector, created in handle_request. It binds winter.web.Request and what the adapter gives (the Django adapter: django.http.HttpRequest).
  • @winter.web.request_scope marks a provider whose value is created once per request; outside a request it raises LookupError.
  • A type taken from the injector must have an explicit binding in it or its parents. Otherwise create_urls fails with TypeError (interceptors registered after that fail on the request). An auto-created object is not enough: a forgotten @request_body would become an empty object.
  • Application no longer calls set_injector.

Removed

  • ArgumentResolver, ArgumentsResolver, arguments_resolver, RequestBodyArgumentResolver, ResponseHeaderArgumentResolver, winter.web.pagination.PagePositionArgumentResolver, winter.django.HttpRequestArgumentResolver. A resolver of a type becomes a provider of that type marked @winter.web.request_scope.
  • The response_headers argument of exception handlers: they declare ResponseHeader[T] with @winter.web.response_header, as API methods do.

Tests

  • tests/test_application_scope.py: one API in two applications gets its argument from the injector of each.
  • tests/web/test_request_scope.py: one value per request, shared by the interceptor and the API method; startup failures.
  • Arguments that used to fail on the first request now fail on startup, so the endpoints that tested the lazy failure are gone.

🤖 Generated with Claude Code

…njector

An argument of an API method, an interceptor or an exception handler is mapped
from the request by Winter's own resolvers (path, query, body, headers, page
position) or comes from the injector of the request, a child of the
application's injector created for each request. Its type must be bound
explicitly; otherwise the URL patterns fail on startup.

@winter.web.request_scope marks a provider whose value is created once per
request. Custom argument resolvers, the Django HttpRequest resolver and the
response_headers argument of exception handlers are gone. Application no
longer installs its injector globally.

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