You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support advanced URI Template Syntax [SPR-10505] #15137
in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
There is an updated RFC for URI templates. Would b cool if we could either add features to current UriTemplate or come up with a dedicated abstraction.
UriTemplate actually delegates to UriComponentsBuilder but I see what you mean. Quite a few options in the spec but I guess we can build a mechanism and then support some or all of them.
Did you have something in mind?
The RFC describes 3 levels of possible implementations that we could target. Note: our current implementation has both expand/match capabilities; so we should consider upgrading both to the same level of implementation.
I guess we'll know more once we try it. Once we add support for operators it may be just as easy to support all operators. On a quick glance levels 2 and 3 at least look pretty useful. /cc Arjen Poutsma
After some further looking, a number of differences have emerged.
Spring's UriComponentsBuilder parses a URI string into constituent components (host, port, path, etc) after which those components can be modified or completely replaced with builder-style methods. URI variables are then expanded into each component and encoding is applied against each (fully expanded) URI component, each according to its own URI syntax (i.e. whatever characters are allowed will not be encoded).
By contrast the RFC provides additional syntax for building up the URI through expressions. Accordingly the required parsing logic is different since the URL structure is not even apparent from the literal parts of the URI template (for example a {?var} will append a query string once expanded). It's two ways of achieving the same thing -- using builder-style methods to build up the URL or relying on variable expressions.
Also the RFC approach to encoding is quite different. In the RFC by default when URI variables are expanded all URI reserved characters are encoded. By contrast UriComponents applies encoding within each component one at at time and according to the syntax for that component.
We have yet to explore a final solution as well as to receive more votes and comments! It's clear however that it won't be a simple flag in the existing UriComponentsBuilder. Rather it will be a new RfcUriComponentsBuilder that may have some relationship to the existing UriComponentsBuilder, or it may not.
Brian Clozel note that I've updated UriTemplateHandler and related classes (as part of #16275) inserting Javadoc that suggests the possibility to create a custom UriTemplateHandler that plugs in an alternative URI template library. I suggest we resolve this as Won't Fix for now.
in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
Activity
spring-projects-issues commentedon May 7, 2013
Rossen Stoyanchev commented
UriTemplate actually delegates to UriComponentsBuilder but I see what you mean. Quite a few options in the spec but I guess we can build a mechanism and then support some or all of them.
spring-projects-issues commentedon Dec 13, 2013
Brian Clozel commented
Did you have something in mind?
The RFC describes 3 levels of possible implementations that we could target. Note: our current implementation has both expand/match capabilities; so we should consider upgrading both to the same level of implementation.
We could even use an existing test suite and the implementation details from the RFC!
spring-projects-issues commentedon Dec 13, 2013
Oliver Drotbohm commented
The current
UriTemplateonly supports the simple string expansions, none of the other expansions work:Even if you use the discovered variable names as is, the expansion doesn't work:
spring-projects-issues commentedon Dec 13, 2013
Rossen Stoyanchev commented
I guess we'll know more once we try it. Once we add support for operators it may be just as easy to support all operators. On a quick glance levels 2 and 3 at least look pretty useful. /cc Arjen Poutsma
spring-projects-issues commentedon Dec 16, 2013
Brian Clozel commented
Assigned to me for the prototyping phase. We'll figure things out after that.
spring-projects-issues commentedon Jan 16, 2014
Oliver Drotbohm commented
We've added support for that in Spring HATEOAS, although in a very limited form.
spring-projects-issues commentedon Sep 17, 2014
Brian Clozel commented
Reconsidering this for 4.2.
We'll see if we can make this happen!
spring-projects-issues commentedon Feb 24, 2015
Rossen Stoyanchev commented
Note that we already support the "/" operator in UrlTag (see #16028) and we'll probably do the same in UriComponentsBuilder (see #17347).
spring-projects-issues commentedon May 4, 2015
Rossen Stoyanchev commented
After some further looking, a number of differences have emerged.
Spring's UriComponentsBuilder parses a URI string into constituent components (host, port, path, etc) after which those components can be modified or completely replaced with builder-style methods. URI variables are then expanded into each component and encoding is applied against each (fully expanded) URI component, each according to its own URI syntax (i.e. whatever characters are allowed will not be encoded).
By contrast the RFC provides additional syntax for building up the URI through expressions. Accordingly the required parsing logic is different since the URL structure is not even apparent from the literal parts of the URI template (for example a {?var} will append a query string once expanded). It's two ways of achieving the same thing -- using builder-style methods to build up the URL or relying on variable expressions.
Also the RFC approach to encoding is quite different. In the RFC by default when URI variables are expanded all URI reserved characters are encoded. By contrast UriComponents applies encoding within each component one at at time and according to the syntax for that component.
We have yet to explore a final solution as well as to receive more votes and comments! It's clear however that it won't be a simple flag in the existing UriComponentsBuilder. Rather it will be a new RfcUriComponentsBuilder that may have some relationship to the existing UriComponentsBuilder, or it may not.
spring-projects-issues commentedon May 14, 2015
Rossen Stoyanchev commented
Postponing since it's a bit late to achieve this for 4.2.
spring-projects-issues commentedon Mar 3, 2016
Rossen Stoyanchev commented
Brian Clozel note that I've updated
UriTemplateHandlerand related classes (as part of #16275) inserting Javadoc that suggests the possibility to create a customUriTemplateHandlerthat plugs in an alternative URI template library. I suggest we resolve this as Won't Fix for now.