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 => $track_id };
POST /album_track { album => $album_id, track => $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
[email protected]
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/