Feat/renderer based response shaping - #36
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.