Is the colon-based template syntax for $resource's url parameter following a standard, or is it AngularJS-specific?

546 Views Asked by At

A REST service I'm working on is sending HATEOAS links back to its AngularJS client. For a few of them, we can't provide the full URL (for lack of information), just a URI Template. We want to follow RFC 6570 (section 3.2.7, "Path-Style Parameter Expansion") to do that. The syntax is {;varName,foo} which the client is supposed to expand to ;varName=bar;foo=baz

A colleague made me aware of AngularJS's documentation for $resource, where a syntax with colons is used: :varName I suppose the equivalent for that would be section 3.2.2 in that RFC (simple string expansion): {varName}, e.g. example.com/order/{orderId}/ would be example.com/order/:orderId/ in that syntax, and expand to .../order/123/

So, first of all, could the colon syntax be used for matrix parameter templates?

Secondly, is that colon syntax defined in a standard/rfc, or is it AngularJS-specific? (The service is supposed to be client-agnostic.)

Last but not least, does AngularJS support RFC6570 out of the box?

P.S.: This is a cross-post from the Angualr-JS mailing list...

1

There are 1 best solutions below

0
Chris DaMour On

you're asking a lot of questions.

No, that angular format is NOT RFC 6570 compliant.

I believe the : prefixed variable syntax for URLs start with Ruby on Rails. I do not know of a spec for that.

googling RFC6570 javascript and RFC6570 angular led to numerous results. i might suggest traverson which has angular extensions, but no it's not supported out of the box.