-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Routing overload #311
Conversation
When user specifies HTTP methods to function handlers, it automatically will be overloaded unless they duplicate. Example: # This is a new route. It works as before. @app.route('/overload', methods=['GET']) async def handler1(request): return text('OK1') # This is the exiting route but a new method. They are merged and # work as combined. The route will serve all of GET, POST and PUT. @app.route('/overload', methods=['POST', 'PUT']) async def handler2(request): return text('OK2') # This is the existing route and PUT method is the duplicated method. # It raises RouteExists. @app.route('/overload', methods=['PUT', 'DELETE']) async def handler3(request): return text('Duplicated')
7207feb
to
11f3c79
Compare
Thanks! Great job @youknowone! |
By the way, writing this patch, I had a question: |
@youknowone That's definitely something we should look into. Maybe it would be beneficial to just default it to |
Not tested this, but the implementation of this could cause this error as far as I can see: |
@AntonDnepr I agree. I never thought about it. I think the mechanism itself is not harmful but its naming makes confusion. How about the class name does not end with 'view' but ends with 'route' that means it is persistent? Like |
When user specifies HTTP methods to function handlers, it automatically
will be overloaded unless they duplicate.
Example: