Hi Kenneth,
about "fast fast fast", there is one important thing we have to
leverage, it's conditional GETs. Ruote-rest is already leveraging it,
but it's custom made. The newer releases of Rack provide middlewares
for simplifying that. Worth considering.
Looking forward to ruote-kit !
--
John Mettraux - http://jmettraux.wordpress.com
Hi List,
I discussed the subject with Kenneth on #ruote. I was thinking about a
tiny step toward the ideal of REST :
making sure that all the representations returned by ruote-kit (and
ruote-web2) include links to the other top resources and flag those
links with a decent "rel" value.
For example, right now, requesting a workitem as JSON, yields something like :
{
"last_modified":"today",
"type":"OpenWFE::InFlowWorkItem",
"participant_name":"hector",
"attributes":{"count":2,"car":"prius"},
"links":[{"href":"\/workitems","rel":"via"},{"href":"\/workitems\/20080919-equestris\/0_0","rel":"self"}],
"dispatch_time":"yesterday",
"flow_expression_id": {
"expression_id":"0.0",
"workflow_definition_url":"http:\/\/test\/test.xml",
"engine_id":"this",
"workflow_definition_name":"test",
"workflow_definition_revision":"1.0",
"workflow_instance_id":"20080919-equestris",
"owfe_version":"0.9.20",
"expression_name":"do-test"}
}
the links in this example are limited (but present) :
"links":[
{"href":"\/workitems","rel":"via"},
{"href":"\/workitems\/20080919-equestris\/0_0","rel":"self"}
]
(note that ruote-web2 and ruote-rest will return absolute links)
I'm planning on adding link to the top resources. In this exampe,
there is only a link to the "/workitems" top resource flagged "via".
I'd like to output something like
"links":[
{"href":"\/workitems","rel":"via"},
{"href":"\/workitems\/20080919-equestris\/0_0","rel":"self"},
{"href":"\/processes","rel":"http://openwferu.rubyforge.org/rels/processes"},
{"href":"\/workitems","rel":"http://openwferu.rubyforge.org/rels/workitems"},
{"href":"\/expressions","rel":"http://openwferu.rubyforge.org/rels/expressions"},
{"href":"\/history","rel":"http://openwferu.rubyforge.org/rels/history"}
]
Note the use of URIs as rel values. Those URIs could be simply markers
in the beginning (ie pointing to nothing), maybe later, the endpoints
could hold something sensible. At least it spares us from petitioning
a microformat [0]. See also [1] and [2].
XML and HTML representations would follow that model as well.
I think that meaningful links and decent representations are at the
heart of a good [tending towards the ideal of] REST interface. REST
doesn't care about nice-looking and human readable URIs for resources,
but fortunately, such URIs are easy to come up with.
What do you guys think ? (In summary, it wouldn't change much, but I
want to communicate that emphasis)
Best regards,
--
John Mettraux - http://jmettraux.wordpress.com
[0] http://microformats.org/wiki/Main_Page
[1] http://tools.ietf.org/id/draft-nottingham-http-link-header-03.txt
- "A link relation type identifies the semantics of a link..."
[2] http://blog.unto.net/web/a-survey-of-rel-values-on-the-web/