Can RFC 6570 URI Templates encode space separators for optional parameters?

226 views Asked by At

I'm working with the US Census API (examples), in which there are optional parameters, which are space-separated. I needed a general-purpose URL templating mechanism, and Google led me to RFC 6570 and its implementations.

But as I understand it, RFC 6570 can't template a query substring like:

...&in=state:02+county:170&...

where "county" may be undefined and should be omitted if so, along with the preceding "+"-encoded space, to leave just

...&in=state:02&...

Can RFC 6570 encode this?

If not, is there an alternative templating syntax for general-purpose URI templating in common use I should consider that's implemented in Javascript and maybe Java?

Is use of a "+" to delimit query sub-elements, as done here, common, or extremely quirky? (I'm asking about frequency-of-use, not whether it's wise!) Is RFC 6570 too restrictive for an application where one is not in control of the URI query syntaxes used?

UPDATE

I see two problems: one is the "+" separator, and the other is the use of ":" in e.g. "state:02", which I don't see how to do either.

0

There are 0 answers