-
Notifications
You must be signed in to change notification settings - Fork 5
Home
biscuit314 edited this page Oct 1, 2014
·
16 revisions
Adding this page really quickly - more prettiness to come.
If a Resource class will use qualified link relations you have two options:
Just name the link relation with a fully qualified name, e.g.
person.Relations.Add("http://example.org/relations/foobar", GetLink());
Or you can add the qualifier to the Resource's Relations
property:
person.Relations.AddQualifier("pointw", "http://example.org/relations/{rel}");
Now that the Resource has this qualifier, you can build link relations like this:
person.Relations.Add("pointw:foobar", GetLink());
That's all you have to worry about at Resource modelling time. The formatter will use this information and create qualified link relations using the capabilities of the media type. For example, HAL would emit the following:
{
"name": "John Doe",
"address": "123 Main St.",
"_links": {
"curies": [
{
"name": "pointw",
"href": "http://api.PointW.WebApi.com/relations/{rel}",
"templated": true
}
],
"pointw:foobar": {
"href": "http://example.org/api/foobar/321"
},
"self": {
"href": "http://example.org/api/person/1"
}
}
}
If the media type does not support curries, the link relation would simply be named something like http://example.org/relations/foobar