[Catalyst] Actions for asserting relationships

Bill Moseley moseley at hank.org
Tue May 31 04:46:37 GMT 2011


I'm looking for more guidance wrt URLs.

Say in the music database example that tracks have a many-to-many
relationship to albums.  A track can be associated with zero or more albums.

In the API for this we can POST, GET, PUT, and DELETE /track and /album.
 But, what about asserting relationships between the two?

POST /album/$album_id/add_track { track  =3D> $track_id };
POST /album_track { album =3D> $album_id, track =3D> $track_id );
POST /album/$album_id/track/$track_id  (or
/track/$track_id/album/$album_id).

The last one seems best as it allows associating other data with the
relationship, and make DELETE make sense.

And what HTTP status code should be returned if a) the relationship is
created? b) the relationship already exists?   I'm not sure it's important
that there's a distinction if only need to assert that the relationship
exists.  But, a 201 really implies that the resource was created.


I suppose to make this more RESTful the $track_id and $album_id should be
URIs in that second example, but makes less sense in the first and third
examples.



-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110530/f7f9f=
dc2/attachment.htm


More information about the Catalyst mailing list