Sha256: 9ade2789e0048cc16e814515bba02d2b87309b27f1b19e0441b03568d24e14e0

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

<h3>Hypermedia representations</h3>

<p>A Restful application should support hypermedia content, and following this constraint, a typical resource representing an order in xml would add controls (links or forms) so clients can navigate through your service protocol (in this case, make a payment):</p>

<pre>
	<%= html '
<order xmlns:atom="http://www.w3.org/2005/Atom">
	<product>rails training</product>
	<product>REST training</product>
	<price>512.45</price>
	<atom:link rel="self" href="http://www.caelum.com.br/orders/1" />
	<atom:link rel="payment" href="http://www.caelum.com.br/orders/1/payment" />
</order>
'%>
</pre>

Here the order is represented through a typical application/xml file, but it has something extra: controls that allows clients to decide what to do next.
Or an <b>example</b> of a valid json representation with hypermedia:

<pre>
{ "order" : {
		"product" : "rails training",
		"product" : "rest training",
		"price" : "512.45"
		"links" : {
			"link" : { "rel" : "self", "href" : "http://www.caelum.com.br/orders/1"},
			"link" : { "rel" : "payment", "href" : "http://www.caelum.com.br/orders/1/payment"}
		}
	}
}
</pre>

Last of all, one could add the links on the Link header of the http response:

<pre>
<%= html 'Link: <http://www.caelum.com.br/orders/1>; rel="self", <http://www.caelum.com.br/orders/1/payment>; rel="payment"' %>
</pre>

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
restfulie-nosqlite-1.0.4 site/app/views/shared/_simple_representation.html.erb
restfulie-1.1.1 site/app/views/shared/_simple_representation.html.erb
restfulie-1.1.0 site/app/views/shared/_simple_representation.html.erb
restfulie-nosqlite-1.0.3 site/app/views/shared/_simple_representation.html.erb
restfulie-1.0.3 site/app/views/shared/_simple_representation.html.erb