The Well-Formed Web

Exploring the limits of XML and HTTP

RESTLog Interface Specification

The RESTLog interface is defined in Table 1. The table lists the URLs, the verbs that can act on those locations, the mime-type of the content and a description of the results of that action.

N.B. The URL RESTLog.cgi is used as a placeholder for the implementations real URL. For example, the real URL could easily be http://bitworking/RESTLog.py or http://WellFormedWeb/news. The RESTLog interface does not define what the URL is, instead it defines the actions that are allowed on that URL and the format of the responses. For example, I can hand you a URL such as http://bitworking.org/stories and tell you that it conforms to the RESTLog interface and you can perform, modulo security restrictions, all of the actions listed below on that URL.

Interface

Table 1
The RESTLog Interface
URL Verb Type Description Format
RESTLog.cgi GET html Retrieves the main web page.
rss Retrieves the RSS file.
POST xml Creates a new news item.RSS Fragment
RESTLog.cgi/itemID GET html Retrieves the item transformed into an HTML page.
xml Retrieves the xml form of the item, i.e. as an RSS 2.0 'item' fragment.RSS Fragment
PUT xml Putting an item replaces it's contents. This is how editing an item is done.RSS Fragment
DELETE - Delete the item.
Verb
The HTTP verbs that can operate on the given URL. HTTP defines a standard set of verbs and we are only using a subset of them here.
Type
Type is just a shorthand for the mime-type of that transaction. Normally selecting the mime type is handled through content negotiation for GETs and specified in the Content-Type for PUTs and POSTs. Content-type can also be forced on a GET by appending a ?Type to any URL. For example, a link to the RSS file would be /RESTLog.cgi?rss.
Table 2
Type mappings
TypeMIME-type
xmltext/xml
htmltext/html
rssapplication/rss+xml

Format

All the actions that deal with content type 'xml' are transporting items. Items are formatted as 'item' elements from RSS 2.0. The items must additionally conform to the RSS 2.0/XSS-extensible profile with the exception of defining the default namespace. For example:

<item xmlns:dc="http://purl.org/dc/elements/1.1/">
      <title>My Summer Vacation</title>
      <description>On my summer vacation I went to...</description>

      <link>http://127.0.0.1/cgi-bin/RESTLog.py/4</link>
      <dc:date>2002-10-28T22:18:53-05:00</dc:date>
</item> 

This example shows only a minimal number of elements. An implementation must no reject modules it doesn't know about, though it is free to ignore them.

Further note that the contents of the 'item' element are guided by the RSS 2.0 specification, which states that all elements are optional, but requires that at least one of 'title' or 'description' are present.

Usage

To create a new item on the weblog the publishing client would format the new item as an 'item' element of RSS 2.0 and POST that to the URL RESTLog.cgi. GET, PUT and DELETE on the URL RESTLog.cgi/itemID are used to manipulate an individual item. The client software can do a GET to retrieve the most recent version of the XML for the item to be displayed for editing by the user. After the user had edited the item it can be PUT back and the items content will be replaced with the PUT copy. Removing an item completely can be done by doing a DELETE on the URL.

Currently most (none?) of the news aggregators don't do content negotiation, so you will need to feed them the URL /RESTLog.cgi?rss which they can use to get the RSS feed.

Notes

13-March-2003
Added some anchors and started removing content negotiation. After using content negotiation in the field for a while it just seems to cause more trouble than it's worth. Many agents do not send 'accept' headers along. This causes problems with validators, transformation agents (like XSLT Services) and possibly buggy browsers. A good rule of thumb I learned from this exercise is "One mime-type per URL".

2003-01-06 11:31 Comments (8)


Joe, is there any predefined format for itemID ?, would 2003/03/1234.html be an acceptable itemID ?

Posted by Simon Fell on 2003-03-26 03:18

like simon, i was working on an implementation that also includes a 'tail' on the itemID. maybe we can define a new configuration element for clients? N.html

Posted by Mike Amundsen on 2003-04-07 08:45

OK, i was foolish and posted raw HTML into the previous comment[sigh]. was attempting this: N.html or .html

Posted by Mike Amundsen on 2003-04-07 08:47

Any notion to adding support for retrieving multiple posts and a collection of appropriate categories to allow for full featured client support? RESTLog.cgi/RecentPosts/numPosts GET RESTLog.cgi/Categories GET I'm basically looking at XML-RPC for metaWeblog.getRecentPosts(unrestian stuff, numPosts) and metaWeblog.getCategoryList(unrestian stuff, blogID which would be implied by location I presume) I'm a REST noob if that's not poignantly obvious, I just think these two items can be reasonably useful from a blog/blog management client perspective.

Posted by Grant Carpenter on 2003-04-08 02:24

Grant, RESTLog.cgi/RecentPosts/numPosts GET isn't this just the RSS feed for the site? As for: RESTLog.cgi/Categories GET The should be handled by 'group' elements of the Archive Format: http://wellformedweb.org/story/6

Posted by Joe on 2003-04-08 11:28

>>isn't this just the RSS feed for the site? Not really the feed per se. Say I want to edit post N-16 and my feed is set for 15 items. How does my client pull back a list of posts, in this case let's just say the last N posts? The archive format would work fine for that though, should a location be defined for it as part of the interface? On the categories question, the only thing I see there is a.) empty group elements need to be returned and b.) what if I just want the categories? Categories are part of what needs to come down as part of initial editing state for basic new/edit post operations, wouldn't it be more work than necessary to pull down all the archive listing too at init (rather than when a client user has indicated, hey I want to do something that actually requires a list of all/some old post)? Just my random thoughts :)

Posted by Grant Carpenter on 2003-04-08 12:52

Grant's point is a good one: the key distinction here is a GET on RESTLog.cgi?rss retrieving "the RSS file" is different if you're subscribing to the feed (at which point you want to get, say, the last 15 articles) or if you're trying to administer your own weblog via the RESTLog interface (at which point you want *all* the articles, so that you can see and edit old ones if you like). I'm not sure how to get around this; clearly serving every article to RSS subscribers is not on te cards, but there's no way then of getting all the articles as far as I can tell.

Posted by Stuart Langridge on 2003-06-07 04:21

I think you are giving up on content negotiation too easily. I’ve seen html and rss successfully overlapped (that is, tolerating broken clients such as Internet Explorer).

I think there is a trick about setting the content negotiation “qs” (quality) variable .999 for the non-html MIME types. This will make the server hand over html when the client doesn’t specify anything.

There is another trick that involves URL rewriting.

All I could dig up on this was a page in German (http://schneegans.de/tips/apache-xhtml/). At the top of the page there is a link to generate an English translation.

Posted by John Belmonte on 2003-08-07 02:13