Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/api/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,22 @@ You then can define request methods like any other HTTP method:
# Handle the custom FOO method
async def on_foo(self, req, resp):
pass

If the HTTP method contains a hyphen or other non-alphanumeric character,
the corresponding responder name will not be a valid Python identifier.
For example, ``VERSION-CONTROL`` maps to ``on_version-control``. In this
case, define the responder as a regular method and then assign it to the
expected responder name on the class with :func:`setattr`::

class VersionControlResource:
def handle_version_control(self, req, resp):
pass


setattr(
VersionControlResource,
'on_version-control',
VersionControlResource.handle_version_control,
)

app.add_route('/repos', VersionControlResource())
Loading