-
Notifications
You must be signed in to change notification settings - Fork 77
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
Components of URL pattern are rewritten(overridden) by subpattern if different names are used #71
Comments
If you have a componentized architecture, the requirement that all (perhaps reusable) components know what variable names other components used seems like a problem, to me. So, I think this is more of a bug than a feature. |
@randallsquared Would it be a security problem or do you think it's prone to abuse? The reason why I think it's a feature is because it enables us to write common Handlers which do validation, authorization, custom logging etc in special cases not covered by the current API.
The authorize handler must access the same URL component in this case, and the framework is forcing us to think in the context of reusable components. |
To be clear, I think it's a bug that using a different name invalidates the first route, if and only if the first parameter name is different (I'm assuming you're correct about this behavior; I haven't tried it). If you have more than one route with a prefix including a parameter, there are two ways (I think) to handle it: use HandleNamespace, or specify the route more than once. If you can't use HandleNamespace, then it seems very likely that the two handlers don't know anything about each other. If two handlers are allowed to specify a parameter placeholder in the same location without namespacing, the name of the parameter shouldn't be required to match: that name is an implementation detail of the handler. So, in my opinion, either tigertonic should overwrite handlers using the same route portion as a parameter every time, or never, but it shouldn't depend on what those handlers need as the parameter name. |
It would be helpful for people not familiar with this nuance if it just panicked when there are conflicting variables. (I just spent a few hours figuring this out. Yay.) Assuming this behaves as intended, then there is a related bug: Tigertonic prints that it handles the first route, when in fact it doesn't, which caused me a lot of confusion and frustration:
Note the conflict in |
Adding handlers for subpatterns overrides the parent pattern if the components are named differently. Ex:
The first handler can never be executed in this scenario. This is a useful feature in my humble opinion, however, it needs to be documented.
The proper way to use it would be:
Just my 2 cents.
The text was updated successfully, but these errors were encountered: