Skip to content

Comments

Add BaseResponse class and ContentT generic to Response#3149

Open
Kludex wants to merge 2 commits intomainfrom
add-base-response
Open

Add BaseResponse class and ContentT generic to Response#3149
Kludex wants to merge 2 commits intomainfrom
add-base-response

Conversation

@Kludex
Copy link
Owner

@Kludex Kludex commented Feb 15, 2026

Continuation of #2547.

Extract BaseResponse from Response to separate responses that use render() (Response, HTMLResponse, JSONResponse, etc.) from those that don't (StreamingResponse, FileResponse). Currently StreamingResponse and FileResponse inherit from Response but never call render() — they only use shared infrastructure (headers, cookies, status code).

Response is now Response(BaseResponse, Generic[ContentT]), and JSONResponse is JSONResponse(Response[ContentT]).

StreamingResponse and FileResponse inherit from BaseResponse directly, and call super().__init__() instead of manually setting attributes.

Breaking changes:

  • StreamingResponse and FileResponse no longer inherit from Response.
  • Type aliases that used Response now use BaseResponse (e.g. HTTPExceptionHandler, RequestResponseEndpoint).

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