Skip to content

refactor(examples): use built-in media handling - #2718

Open
Chaz0rk wants to merge 1 commit into
falconry:masterfrom
Chaz0rk:issue-2309-things-advanced
Open

refactor(examples): use built-in media handling#2718
Chaz0rk wants to merge 1 commit into
falconry:masterfrom
Chaz0rk:issue-2309-things-advanced

Conversation

@Chaz0rk

@Chaz0rk Chaz0rk commented Aug 23, 2026

Copy link
Copy Markdown

Summary of Changes

  • Replace the custom JSONTranslator middleware in the WSGI and ASGI examples with Falcon's built-in media handling.
  • Use req.get_media() in the WSGI POST responder and await req.get_media() in the ASGI POST responder.
  • Assign response data to resp.media so that Falcon serializes it automatically
  • Update the mirrored examples in README.rst.
  • Revise “problems in your API” to “problems in your App”.

Removing the custom middleware also prevents a bodyless ASGI GET request from being incorrectly rejected when the Content-Length header is absent.

Testing

  • Ran the full tox suite successfully.
  • Exercised GET and POST requests for both WSGI and ASGI with falcon.testing.TestClient.
  • Verified 200 OK for GET and 201 Created for 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.

    • Added docstrings for any new classes, functions, or modules.
    • Updated docstrings for any modifications to existing code.
    • Updated both WSGI and ASGI docs (where applicable).
    • Added references to new classes, functions, or modules to the relevant RST file under docs/.
    • Updated all relevant supporting documentation files under docs/.
    • A copyright notice is included at the top of any new modules (using your own name or the name of your organization).
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • 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.

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

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ea2b14d) to head (1212132).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Revamp things-advanced (WSGI/ASGI) examples

1 participant