Skip to content

Tech debt: Generate HTTP method decorators programmatically #8119

@leandrodamascena

Description

@leandrodamascena

Why is this needed?

get(), post(), put(), delete(), patch(), head(), options() in BaseRouter are 7 methods with identical signatures that just call self.route(rule, "METHOD", ...). A loop or factory can generate them.

Steps:

  1. Create a factory function that produces the decorator method for a given HTTP method
  2. Register all 7 methods in BaseRouter using the factory
  3. Preserve type hints and docstrings for IDE support
  4. Verify that Router and all resolver subclasses still work

Which area does this relate to?

Event Handler - REST API

Suggestion

No response

Acknowledgment

Metadata

Metadata

Labels

tech-debtTechnical Debt tasks

Projects

Status

Coming soon

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions