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
Support for URLs in route decorator #154
Comments
I feel super bad for @mksh now, having put all this work into #163, but… looking at this PR, I was wondering… why? First and foremost, what's the benefit of allowing this? On the "why" not side, it seems like using URL here just adds some type confusion here, because how do you specify that you want a placeholder and a parameter here? Adding |
That cab easily be checked by |
Well, here's an example. I have a bunch of URLs for my application somewhere; I need to use them in places other than the route decorators because elsewhere I want to have links to them, and I always use these constants. That means that in the route decorates, I'm always calling
I'm not sure why you'd be calling |
Thanks for the more detailed explanation! |
I'm not suggesting that one does, but rather, that including |
Moreover it feels to me (in a somewhat vague, abstract way; I'm open to being convinced that this is silly) that some normalization ought to be standard-ly applied when we accept URLs here, so as to avoid weirdness. Is that just |
Verifying that |
One potential issue / antipattern with this idiom is that the parametric portions of the URL which cause Klein to pass you extra arguments are now hidden behind an extra layer of indirection. Maybe this is just fine, but it feels like a slightly odd departure from the way klein apps usually co-locate their parameter descriptions and their function declarations. On the other hand this is consistent with the ongoing work on #126 , which does move the form parameters to be somewhat more distant from the method definition. So I'm kinda just thinking out loud here. |
It's possible that something like #173 will change my mind here, which is to say that instead of constants somewhere, I can add a rout for it's URL, and that would be how I get that URL elsewhere, and asking could require that I provide the parametrized components, solving that weirdness also. More thinking out loud: A problem I'm running into is that in cases where you have a composed application (App A has routes into App B), you need to somehow be able to compose the URLs, though that's a problem with the "URL constants list somewhere" approach. That, perhaps, is orthogonal and should be thought about primarily in another ticket (I think composition is harder than is desirable), but I want to make sure that we think through it a little bit here, as it seems related. Here's my example… I have this web app. Note the *Application attributes, which are the child applications, and the route methods ("*Endpoint") for them at the bottom of the file. Then not that in this child application, I have this janky This is a lame coupling of the child applications to the parent, so poor composition (these used to be mix-in classes, so it's better than what I had before), and I haven't thought of a natural way to get rid of it. |
I guess what this means is that #173's |
@wsanchez, I came to Klein from the But (It is possible though that klein app isn't running on the root of url space, for example by reverse-proxying. Possible way to deal with it is to pass some |
@IlyaSkriblovsky thanks, this is useful |
The
route
decorator should acceptURL
objects as well as strings.The text was updated successfully, but these errors were encountered: