deblockt / hal-rest-client

Typescript HAL Rest client
Apache License 2.0
25 stars 11 forks source link

Template links #9

Closed vdytynyuk closed 7 years ago

vdytynyuk commented 7 years ago

It seems that library doesn't work with parsing template links. Are you going to implement templates support?

deblockt commented 7 years ago

It's fine, it's not yet implemented. I will do that. Can you provide an example of what do you expect?

vdytynyuk commented 7 years ago

@deblockt For instance I receive such template - runs/42/files{/path*} and I want to be able to nicely concatenate some path to the prefix of this link. Is it possible?

Smolli commented 7 years ago

@deblockt Spring Data for example also provides some URLs that take optional parameters like /bookings{?projection}. So if you call the URL, I want to be able to add a value for that parameter. So in the end, the URL looks like /bookings?projection=excerpt. Without setting the parameter, the URL should read /bookings. Will you consider this too?

deblockt commented 7 years ago

Yes, i will consider that. But this breaks the existing functioning of links I will study this issue.

deblockt commented 7 years ago

Templated links are now supported on version 0.3.0. When you call fetchmethod you can pass object as argument to set url parameters (see https://github.com/deblockt/hal-rest-client#follow-a-templated-link). Warning, now HalResource.uri is an URI object and not a string (see https://github.com/deblockt/hal-rest-client#from-o2).