Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle creation links ... #36

Open
jamesladd opened this issue Jun 20, 2012 · 5 comments
Open

How to handle creation links ... #36

jamesladd opened this issue Jun 20, 2012 · 5 comments

Comments

@jamesladd
Copy link

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.

@talios
Copy link
Owner

talios commented Jun 20, 2012

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:
#36

@jamesladd
Copy link
Author

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:
#36


Reply to this email directly or view it on GitHub:
#36 (comment)

@jamesladd
Copy link
Author

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:
#36


Reply to this email directly or view it on GitHub:
#36 (comment)

@talios
Copy link
Owner

talios commented Jun 20, 2012

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: ''
}
}

@jamesladd
Copy link
Author

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:
#36 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants