Resources and Classes

by Subbu Allamaraju on October 2, 2008

What is the closest thing to a class or type in RESTful systems?

I think it is the media type. URIs name resources, but don't describe types. Media types, on the other hand, describe representations. A representation is the closest thing to an object. Media types describe types of representations.

That's why, the more specific the media types are, the better. Using a generic type like application/xml is like using a generic class like java.lang.Object (or its equivalent in other languages).

{ 2 comments… read them below or add one }

1 BC October 3, 2008 at 5:17 am

Doesn’t that trip up clients like XHR that count on an known XML media type to recognize and parse the XML document?

Reply

2 subbu October 3, 2008 at 7:44 am

Not necessarily. XHR can recognize XML-ish content-types ending with +xml, such as application/atom+xml, application/mystuff+xml etc.

Reply

Leave a Comment

Previous post:

Next post: