Skip to content

Feat/renderer based response shaping - #36

Merged
ARYAN-NIKNEZHAD merged 2 commits into
mainfrom
feat/renderer-based-response-shaping
Jul 30, 2026
Merged

Feat/renderer based response shaping#36
ARYAN-NIKNEZHAD merged 2 commits into
mainfrom
feat/renderer-based-response-shaping

Conversation

@ARYAN-NIKNEZHAD

Copy link
Copy Markdown
Contributor

No description provided.

Keep the local Claude Code guidance file out of version control.
Move successful/error response shaping out of DynamicResponseMiddleware and
into a new DRF JSONRenderer subclass, ShapedJSONRenderer. The renderer wraps
response.data into the envelope before serialization, so the body is serialized
exactly once. The previous middleware read response.data (or json.loads on the
rendered content) and rebuilt a fresh JsonResponse, forcing an extra
decode/re-encode cycle that was slow for large payloads.

DynamicResponseMiddleware is now slimmed down to structuring raw Django
exceptions only (process_exception); it passes normal responses through
untouched. Custom success/error handlers keep feature parity via the same
RESPONSE_SHAPER_SUCCESS_HANDLER / RESPONSE_SHAPER_ERROR_HANDLER settings.

Tests and docs updated; coverage stays at 100%.

BREAKING CHANGE: response shaping now requires enabling
response_shaper.renderers.ShapedJSONRenderer via DEFAULT_RENDERER_CLASSES (or a
view's renderer_classes); the middleware no longer shapes successful/error
responses. Custom handler signature changed from (response) -> JsonResponse to
(data, status_code, renderer_context) -> dict.
@ARYAN-NIKNEZHAD ARYAN-NIKNEZHAD self-assigned this Jul 30, 2026
@ARYAN-NIKNEZHAD ARYAN-NIKNEZHAD added documentation Improvements or additions to documentation enhancement New feature or request labels Jul 30, 2026
@ARYAN-NIKNEZHAD
ARYAN-NIKNEZHAD merged commit e9232b3 into main Jul 30, 2026
0 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant