falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.51k stars 937 forks source link

Allow to override the default responders via `on_request()` #2071

Open vytas7 opened 2 years ago

vytas7 commented 2 years ago

In addition to on_get(), on_post(), etc, could we allow redefining the default responders via a generic on_request()? This idea is borrowed from the Responder framework (which is in turned inspired by Falcon and Flask), see: Class-Based Views.

Responder itself is sort of abandoned, so it was challenging to even get a test program running, but once I got it up, it seemed that providing both on_request() AND on_get() in Responder makes the said framework call both upon GET. Which IMHO doesn't fit well into Falcon's design, so maybe we could instead map on_request (if provided) only instead of the default responders. See also: https://github.com/falconry/falcon/issues/735.

Opinions welcome on what to do with on_options(), if not provided. Maybe we could still provide a default on_options(), and not use on_request() for that, in order to minimize the breaking impact of this change, and for convenience.

This change could potentially pave the way to further unifying resources and sinks, see also