Skip to content

docs: document responders for hyphenated HTTP methods#2653

Open
mvanhorn wants to merge 4 commits into
falconry:masterfrom
mvanhorn:fix/2647-responders-hyphenated-http-methods
Open

docs: document responders for hyphenated HTTP methods#2653
mvanhorn wants to merge 4 commits into
falconry:masterfrom
mvanhorn:fix/2647-responders-hyphenated-http-methods

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Falcon resolves responders by looking up on_<method> attributes on a resource. That means a responder for an HTTP method whose name contains a hyphen or other non-alphanumeric character (for example a WebDAV-style VERSION-CONTROL method) cannot be written as an ordinary method, because on_version-control is not a valid Python identifier. This is a real but rare limitation, and the maintainers confirmed in the thread that no routing code change is warranted.

Both vytas7 and CaselIT converged on a documentation-only resolution: explain the limitation and show the supported workaround. The agreed workaround is to register the responder imperatively with setattr(resource, 'on_version-control', handler), which the existing attribute-based dispatch picks up at request time exactly as it would for a normally-named responder.

This change adds a short note to the routing docs describing the limitation and that workaround, keeping the example minimal and consistent with the surrounding Google-style docs. It also adds a 2647.misc.rst towncrier news fragment. No runtime routing or dispatch code is touched, matching the maintainers' stated decision in the issue.

Related Issues

Closes #2647

Pull Request Checklist

  • Applied changes to both WSGI and ASGI code paths and interfaces (where applicable) — n/a, documentation only and the limitation is shared by both
  • Added tests for changed code — n/a, documentation only
  • Performed automated tests and code quality checks — n/a, no code changed
  • Prefixed code comments with GitHub nick and an appropriate prefix — n/a, no code comments added
  • Coding style is consistent with the rest of the framework
  • Updated documentation for changed code
  • Added a towncrier news fragment under docs/_newsfragments/ (2647.misc.rst)
  • LLM output has been carefully reviewed and tested by a human developer

Comment thread docs/_newsfragments/2647.misc.rst Outdated
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (370f933) to head (094df54).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2653   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           64        64           
  Lines         7985      7985           
  Branches      1103      1103           
=========================================
  Hits          7985      7985           

☔ 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.

@CaselIT CaselIT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prose is fine, just a minor note on the example code

Comment thread docs/api/routing.rst Outdated
pass


resource = VersionControlResource()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would dp this on the class instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 094df54. Moved the setattr onto the class and verified the example end to end: a VERSION-CONTROL request against the snippet resolves the responder and returns 200.

Per review, set the responder with setattr on the class rather than on
a bound instance method.
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.

Cumbersome to define responders for HTTP methods containing hyphens

3 participants