Você está na página 1de 34

Spring MVC REST

1
Steps in designing Rest Applications
• Restful Application design typically has following steps :
 Resource Identification
 Resource Representation
 Endpoint Identification
 Verb/Action Identification

Sivaprasad.valluru@gmail.com
Resource Identification
• Following are the resources(nouns)

 Clusters
 Cluster
 ServerGroups
 ServerGroup
 Servers
 Server
 Deployments
 Deployment

Sivaprasad.valluru@gmail.com
Get /servers implementations

Sivaprasad.valluru@gmail.com
GET /servers/{id} example

Sivaprasad.valluru@gmail.com
POST /servers

Sivaprasad.valluru@gmail.com
GET /clusters

Sivaprasad.valluru@gmail.com
GET /clusters/{id}

Sivaprasad.valluru@gmail.com
DELETE /clusters/{id}

Sivaprasad.valluru@gmail.com
PUT /clusters/{id}

Sivaprasad.valluru@gmail.com
GET all server belonging to a cluster

Sivaprasad.valluru@gmail.com
Sivaprasad.valluru@gmail.com
CLIENT USING REST TEMPLATE

Sivaprasad.valluru@gmail.com
Get request with out response headers

Sivaprasad.valluru@gmail.com
Get Request with response headers

Sivaprasad.valluru@gmail.com
Using ParameterizedTypeReference

Sivaprasad.valluru@gmail.com
POST with out headers

Sivaprasad.valluru@gmail.com
POST with headers

Sivaprasad.valluru@gmail.com
PAGING

Sivaprasad.valluru@gmail.com
Implementing Paging

Sivaprasad.valluru@gmail.com
Customizing paging

Sivaprasad.valluru@gmail.com
SPRING-HATEOS

Sivaprasad.valluru@gmail.com
ResourceSupport
• Make all your Resource classes to extend ResourceSupport

Sivaprasad.valluru@gmail.com
Creating Links

• If your domain class implements the Identifiable interface


the slash(…) method will rather invoke getId() on the given
object instead of toString()

Sivaprasad.valluru@gmail.com
Link to URI
• The builder also allows creating URI instances to build up e.g.
response header values:

Sivaprasad.valluru@gmail.com
Sivaprasad.valluru@gmail.com
Sivaprasad.valluru@gmail.com
Sivaprasad.valluru@gmail.com
RESOURCE ASSEMBLER

Sivaprasad.valluru@gmail.com
Sivaprasad.valluru@gmail.com
Using Resource Assembler

Sivaprasad.valluru@gmail.com
Sivaprasad.valluru@gmail.com
SPRING DATA REST

Sivaprasad.valluru@gmail.com
Sivaprasad.valluru@gmail.com

Você também pode gostar