halbuilder icon indicating copy to clipboard operation
halbuilder copied to clipboard

How to handle creation links ...

Open jamesladd opened this issue 13 years ago • 5 comments

This isn't so much an issue as a question, how does HAL expect links that require more than a simple {} template to be handled? ie: a form.

jamesladd avatar Jun 20 '12 03:06 jamesladd

The simple answer for this is that HAL doesn't care. How links templates are processed arn't really a concern for HAL itself.

The RTC for UriTemplates is at:

http://tools.ietf.org/html/rfc6570

and for a form, you would need to use a Level 3 compliant UriTemplate parser, and would be expressed as:

http://example.com/{?firstName,lastName,emailAddress}

which would be expanded to:

http://example.com?firstName=Mark&lastName=Derricutt&[email protected]

Mark

On 20/06/12 3:03 PM, James Ladd wrote:

This isn't so much an issue as a question, how does HAL expect links that require more than a simple {} template to be handled? ie: a form.


Reply to this email directly or view it on GitHub: https://github.com/talios/halbuilder/issues/36

talios avatar Jun 20 '12 03:06 talios

Thanks for the quick reply.

I'm reading through that RFC and I can see how the template can be used.

I'm guessing it is 'assumed' that the template along with HTTP Verbs are enough to work with the resource. ie: POST with params creates the resource?

  • James.

On Wed, Jun 20, 2012 at 1:18 PM, Mark Derricutt < [email protected]

wrote:

The simple answer for this is that HAL doesn't care. How links templates are processed arn't really a concern for HAL itself.

The RTC for UriTemplates is at:

http://tools.ietf.org/html/rfc6570

and for a form, you would need to use a Level 3 compliant UriTemplate parser, and would be expressed as:

http://example.com/{?firstName,lastName,emailAddress}

which would be expanded to:

http://example.com?firstName=Mark&lastName=Derricutt&[email protected]

Mark

On 20/06/12 3:03 PM, James Ladd wrote:

This isn't so much an issue as a question, how does HAL expect links that require more than a simple {} template to be handled? ie: a form.


Reply to this email directly or view it on GitHub: https://github.com/talios/halbuilder/issues/36


Reply to this email directly or view it on GitHub: https://github.com/talios/halbuilder/issues/36#issuecomment-6444150

jamesladd avatar Jun 20 '12 03:06 jamesladd

Oh - Im guessing it would be expected that should a template parameter be used, then there would also be a link of the same name to indicate the list of acceptable values?

'_links': { 'search' : { href: '/search{?names}', templated: true }, 'names' : { href: '' } }

On Wed, Jun 20, 2012 at 1:20 PM, James Ladd [email protected] wrote:

Thanks for the quick reply.

I'm reading through that RFC and I can see how the template can be used.

I'm guessing it is 'assumed' that the template along with HTTP Verbs are enough to work with the resource. ie: POST with params creates the resource?

  • James.

On Wed, Jun 20, 2012 at 1:18 PM, Mark Derricutt < [email protected]

wrote:

The simple answer for this is that HAL doesn't care. How links templates are processed arn't really a concern for HAL itself.

The RTC for UriTemplates is at:

http://tools.ietf.org/html/rfc6570

and for a form, you would need to use a Level 3 compliant UriTemplate parser, and would be expressed as:

http://example.com/{?firstName,lastName,emailAddress}

which would be expanded to:

http://example.com?firstName=Mark&lastName=Derricutt&[email protected]

Mark

On 20/06/12 3:03 PM, James Ladd wrote:

This isn't so much an issue as a question, how does HAL expect links that require more than a simple {} template to be handled? ie: a form.


Reply to this email directly or view it on GitHub: https://github.com/talios/halbuilder/issues/36


Reply to this email directly or view it on GitHub: https://github.com/talios/halbuilder/issues/36#issuecomment-6444150

jamesladd avatar Jun 20 '12 03:06 jamesladd

How the templates are resolved I suspect would be really up to you, and defined by how you document your link rel.

In the few examples I've looked at using UriTemplates for I've been assuming the template parameters would be sourced primarily from the fields of the resource itself, with any additional parameters from somewhere "magic" ;)

i.e.

{ '_links': { 'cancel' : { 'href': '{base}/customer-cancellation{?id,comment}', 'templated' : true } }, 'id': 2342 }

In what ever documentation for the "cancel" rel, I'd state that the 'comment' field is used supplied, with the rest from the resource.

Mark

On 20/06/12 3:24 PM, James Ladd wrote:

Oh - Im guessing it would be expected that should a template parameter be used, then there would also be a link of the same name to indicate the list of acceptable values?

'_links': { 'search' : { href: '/search{?names}', templated: true }, 'names' : { href: '' } }

talios avatar Jun 20 '12 03:06 talios

Gotcha.

On Wed, Jun 20, 2012 at 1:34 PM, Mark Derricutt < [email protected]

wrote:

How the templates are resolved I suspect would be really up to you, and defined by how you document your link rel.

In the few examples I've looked at using UriTemplates for I've been assuming the template parameters would be sourced primarily from the fields of the resource itself, with any additional parameters from somewhere "magic" ;)

i.e.

{ '_links': { 'cancel' : { 'href': '{base}/customer-cancellation{?id,comment}', 'templated' : true } }, 'id': 2342 }

In what ever documentation for the "cancel" rel, I'd state that the 'comment' field is used supplied, with the rest from the resource.

Mark

On 20/06/12 3:24 PM, James Ladd wrote:

Oh - Im guessing it would be expected that should a template parameter be used, then there would also be a link of the same name to indicate the list of acceptable values?

'_links': { 'search' : { href: '/search{?names}', templated: true }, 'names' : { href: '' } }


Reply to this email directly or view it on GitHub: https://github.com/talios/halbuilder/issues/36#issuecomment-6444281

jamesladd avatar Jun 20 '12 03:06 jamesladd