-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
finish uri template implementation #3227
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
Comments
Guzzle seems to have added support: |
Which part would like to add support for (which would be relevant for the Routing component)? |
Support for query parameters ? |
yeah .. afaik we also wanted to support the syntax for defining default values |
URI templates don't necessarily provide a syntax for defining default values or representing a resource location, but rather place holders and modifiers that determine how an associative array of variables are injected into a URI. I went through each example in the URI templates draft 08 and tested Guzzle against them. For a list of these use cases, see https://github.com/guzzle/guzzle/blob/master/tests/Guzzle/Tests/Http/UriTemplateTest.php#L39-L112 This excerpt somewhat touches on this subject:
I could see how adding some of the modifier support of URI templates could be helpful, where the modifiers specify whether a variable is url-encoded (prefix with +), how an array of values are imploded (suffix with *), etc. What are your thoughts? |
I read the URI template draft and must say I see no reason why the routing component should implement this syntax and semantics. The URI template also includes this variable expansion for query parameters and anchors. But anchors do not really belong in the routing as they are not used for matching URLs (and should not). And generating URLs with anchors can easily be solved outside the routing. Such feature request has already been closed by Fabien: #3910 The only thing that might make sense is adding support for query parameters in the routing layer. But the benefit is not big. Setting defaults for the query params can easiliy be achieved in the controller: So all in all it might make sense to add support for query params in the routing layer, but that would have nothing to do with URI template draft. URI template does not allow defining defaults anyway and its syntax with variable expansion is nothing we need or should promote. So I would close this issue and open a new feature request with only query params in routing layer. |
Yeah, I was mainly interested in query support. The main benefit I see from putting it in the routing is that it would give us a canonical way to specify this sort of thing to enable reusing the information in other places:
see also FriendsOfSymfony/FOSRestBundle#185 |
@henrikbjorn reminded me this morning that we intended to revisit this topic after 2.0 stable
http://code.google.com/p/uri-templates/
the main thing to add is support for query parameters. these would however not be used for the matching process in the Routing layer. it would only be used to automatically set the given parameters as request attributes so that they can optionally be passed to actions. also this would allow setting default value for query parameters.
The text was updated successfully, but these errors were encountered: