refactor(examples): use built-in media handling - #2718
Open
Chaz0rk wants to merge 1 commit into
Open
Conversation
Use Falcon media handlers instead of the custom JSON translator in the WSGI and ASGI examples. Keep the mirrored README examples in sync and update App terminology. Closes falconry#2309
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2718 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 64 64
Lines 7990 7990
Branches 1106 1106
=========================================
Hits 7990 7990 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary of Changes
JSONTranslatormiddleware in the WSGI and ASGI examples with Falcon's built-in media handling.req.get_media()in the WSGI POST responder andawait req.get_media()in the ASGI POST responder.resp.mediaso that Falcon serializes it automaticallyREADME.rst.Removing the custom middleware also prevents a bodyless ASGI GET request from being incorrectly rejected when the
Content-Lengthheader is absent.Testing
toxsuite successfully.falcon.testing.TestClient.200 OKfor GET and201 Createdfor POST in both variants.No permanent tests were added because this PR changes only the examples and their mirrored README snippets, rather than Falcon framework functionality.
LLM Usage
LLM assistance was used to explain coding concepts, suggest implementation and testing steps, help me use Git, and review grammar. It did not autonomously modify any code. I manually applied, reviewed, and tested every proposed change, discarding suggestions that did not convince me.
Related Issues
Closes #2309
Pull Request Checklist
This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. Reading our [contribution guide](https://falcon.readthedocs.io/en/stable/community/contributing.html) at least once will save you a few review cycles!
If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing to do.
Applied changes to both WSGI and ASGI code paths and interfaces (where applicable).
Added tests for changed code.
Performed automated tests and code quality checks by running
tox.Prefixed code comments with GitHub nick and an appropriate prefix.
Coding style is consistent with the rest of the framework.
Updated documentation for changed code.
docs/.docs/.versionadded,versionchanged, ordeprecateddirectives.Changes (and possible deprecations) have towncrier news fragments under
docs/_newsfragments/.LLM output, if any, has been carefully reviewed and tested by a human developer.