REST documentation

This commit is contained in:
Mark Pollack 2009-04-11 05:59:12 +00:00
parent 4fc77944ad
commit d16d8984a8
1 changed files with 29 additions and 30 deletions

View File

@ -2,7 +2,7 @@
<chapter id="rest"> <chapter id="rest">
<title>REST support</title> <title>REST support</title>
<section> <section id="rest-introduction">
<title>Introduction</title> <title>Introduction</title>
<para>The goal of Spring's REST support is to make the development of <para>The goal of Spring's REST support is to make the development of
@ -32,7 +32,7 @@
model.</para> model.</para>
</section> </section>
<section> <section id="rest-creating-services">
<title>Creating RESTful services</title> <title>Creating RESTful services</title>
<para>Spring's annotation-based MVC framework serves as the basis for <para>Spring's annotation-based MVC framework serves as the basis for
@ -40,7 +40,7 @@
container as you would for a Spring MVC application using Spring's <link container as you would for a Spring MVC application using Spring's <link
linkend="mvc-servlet">DispatcherServlet</link>.</para> linkend="mvc-servlet">DispatcherServlet</link>.</para>
<section> <section id="rest-uritemplate">
<title>URI templates</title> <title>URI templates</title>
<para>RESTful services use URIs to name resourses. To faciliate <para>RESTful services use URIs to name resourses. To faciliate
@ -75,7 +75,7 @@ public String getUser(@PathVariable String userId) {
<para>The request <literal>http://www.example.com/users/fred</literal> <para>The request <literal>http://www.example.com/users/fred</literal>
will bind the userId method parameter to the String value 'fred'.</para> will bind the userId method parameter to the String value 'fred'.</para>
<section id="path-variable"> <section id="rest-path-variable">
<title>Mapping RESTful URLs with the @PathVariable annotation</title> <title>Mapping RESTful URLs with the @PathVariable annotation</title>
<para>The <classname>@PathVariable</classname> method level annotation <para>The <classname>@PathVariable</classname> method level annotation
@ -159,7 +159,7 @@ public class RelativePathUriTemplateController {
</section> </section>
</section> </section>
<section> <section id="rest-multiple-representations">
<title>Returning multiple representations</title> <title>Returning multiple representations</title>
<para>A RESTful architecture may expose multiple representations of a <para>A RESTful architecture may expose multiple representations of a
@ -273,7 +273,7 @@ public class RelativePathUriTemplateController {
<classname>SampleContentAtomView</classname> if the view name returned <classname>SampleContentAtomView</classname> if the view name returned
is 'content'. Alternatively, client requests could be made without a is 'content'. Alternatively, client requests could be made without a
file extension and setting the Accept header to the preferred media-type file extension and setting the Accept header to the preferred media-type
and the same resolution of request to views would be occur.</para> and the same resolution of request to views would occur.</para>
<note> <note>
<para>If <classname>ContentNegotiatingViewResolver</classname>'s list <para>If <classname>ContentNegotiatingViewResolver</classname>'s list
@ -306,19 +306,19 @@ public class ContentController {
<para></para> <para></para>
</section> </section>
<section> <section id="rest-views">
<title>Views</title> <title>Views</title>
<para>blah</para> <para>blah</para>
</section> </section>
<section> <section id="rest-method-conversion">
<title>HTTP Method Conversion</title> <title>HTTP Method Conversion</title>
<para>Another key principle of REST is the use of the Uniform Interface. <para>A key principle of REST is the use of the Uniform Interface. This
This means that all resources (URLs) can be manipulated using the same means that all resources (URLs) can be manipulated using the same four
four HTTP method: GET, PUT, POST, and DELETE. For each of methods, the HTTP method: GET, PUT, POST, and DELETE. For each methods, the HTTP
HTTP specification defines exact semantics. For instance, a GET should specification defines the exact semantics. For instance, a GET should
always be a safe operation, meaning that is has no side effects, and a always be a safe operation, meaning that is has no side effects, and a
PUT or DELETE should be idempotent, meaning that you can repeat these PUT or DELETE should be idempotent, meaning that you can repeat these
operations over and over again, but the end result should be the same. operations over and over again, but the end result should be the same.
@ -326,15 +326,14 @@ public class ContentController {
POST. Fortunately, there are two possible workarounds: you can either POST. Fortunately, there are two possible workarounds: you can either
use JavaScript to do your PUT or DELETE, or simply do a POST with the use JavaScript to do your PUT or DELETE, or simply do a POST with the
'real' method as an additional parameter (modeled as a hidden input 'real' method as an additional parameter (modeled as a hidden input
field in an HTML form). This latter trick is what the field in an HTML form). This latter trick is what Spring's
<classname>HiddenHttpMethodFilter</classname> does. This filter was <classname>HiddenHttpMethodFilter</classname> does. This filter is a
introduced in Spring 3.0 M1, and is a plain Servlet Filter. As such, it plain Servlet Filter and therefore it can be used in combination with
can be used in combination with any web framework (not just Spring MVC). any web framework (not just Spring MVC). Simply add this filter to your
Simply add this filter to your web.xml, and a POST with a hidden _method web.xml, and a POST with a hidden _method parameter will be converted
parameter will be converted into the corresponding HTTP method into the corresponding HTTP method request.</para>
request.</para>
<section> <section id="rest-form-tags">
<title>Supporting Spring form tags</title> <title>Supporting Spring form tags</title>
<para>To support HTTP method conversion the Spring MVC form tag was <para>To support HTTP method conversion the Spring MVC form tag was
@ -358,7 +357,7 @@ public String deletePet(@PathVariable int ownerId, @PathVariable int petId) {
</section> </section>
</section> </section>
<section> <section id="rest-etag">
<title>ETag support</title> <title>ETag support</title>
<para>An <ulink <para>An <ulink
@ -397,30 +396,30 @@ public String deletePet(@PathVariable int ownerId, @PathVariable int petId) {
or an AspectJ aspect.</para> or an AspectJ aspect.</para>
</section> </section>
<section> <section id="rest-exception">
<title>Exception Handling</title> <title>Exception Handling</title>
<para>@ExceptionHandler</para> <para>@ExceptionHandler</para>
</section> </section>
</section> </section>
<section> <section id="rest-client-access">
<title>Accessing RESTful services on the Client</title> <title>Accessing RESTful services on the Client</title>
<para>Spring provides a client-side API blah blah</para> <para>Spring provides a client-side API blah blah</para>
<section> <section id="rest-resttemplate">
<title>RestTemplate</title> <title>RestTemplate</title>
<para>blah blah</para> <para>blah blah</para>
</section> </section>
<section> <section id="rest-message-conversion">
<title>HTTP Message Conversion</title> <title>HTTP Message Conversion</title>
<para>blah blah</para> <para>blah blah</para>
<section> <section id="rest-string-converter">
<title>StringHttpMessageConverter</title> <title>StringHttpMessageConverter</title>
<para></para> <para></para>
@ -428,7 +427,7 @@ public String deletePet(@PathVariable int ownerId, @PathVariable int petId) {
<para></para> <para></para>
</section> </section>
<section> <section id="rest-form-converter">
<title>FormHttpMessageConverter</title> <title>FormHttpMessageConverter</title>
<para></para> <para></para>
@ -436,7 +435,7 @@ public String deletePet(@PathVariable int ownerId, @PathVariable int petId) {
<para></para> <para></para>
</section> </section>
<section> <section id="rest-byte-converter">
<title>ByteArrayMessageConverter</title> <title>ByteArrayMessageConverter</title>
<para></para> <para></para>
@ -444,7 +443,7 @@ public String deletePet(@PathVariable int ownerId, @PathVariable int petId) {
<para></para> <para></para>
</section> </section>
<section> <section label="rest-marhsalling-converter">
<title>MarshallingHttpMessageConverter</title> <title>MarshallingHttpMessageConverter</title>
<para></para> <para></para>
@ -452,7 +451,7 @@ public String deletePet(@PathVariable int ownerId, @PathVariable int petId) {
<para></para> <para></para>
</section> </section>
<section> <section id="rest-source-converter">
<title>SourceHttpMessageConverter</title> <title>SourceHttpMessageConverter</title>
<para></para> <para></para>