Skip to content
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

Raise a warning on adding duplicated resource #3023

Open
asvetlov opened this issue May 22, 2018 · 4 comments
Open

Raise a warning on adding duplicated resource #3023

asvetlov opened this issue May 22, 2018 · 4 comments

Comments

@asvetlov
Copy link
Member

Now, add_route merges consequenced add_get(path, handler) and add_post(path, handler) calls but doesn't do it if a resource for other path is pushed in between calls.
Also, it doesn't merge the same resource but under different names.

Let's not change behavior but raise a user warning for such cases, most likely it is the result of silly mistake/misunderstanding.

@pposca
Copy link
Contributor

pposca commented May 23, 2018

What is the reason for merging only consequenced calls? I mean, if you have to detect non-consecutive calls or the same resource under different names to send a warning, why not just merge all cases?

@asvetlov
Copy link
Member Author

Good question!

Consider the following:

[get('/{arg}', h1),
 post(r'/{num:\d+}', h2),
 post('/{arg}', h3)]

Looks weird (and sure it is).
But the example demonstrates the real problem.
By merging /{arg} handlers /{num:\d+} will be never called.

@pposca
Copy link
Contributor

pposca commented May 23, 2018

Of course, the order is important. I didn't realize it. Now, I understand it. I will have a look at it. Thanks.

@asvetlov
Copy link
Member Author

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants