# Web Server2(Spring REST)

[https://dzone.com/articles/creating-a-rest-api-with-java-and-spring](https://dzone.com/articles/creating-a-rest-api-with-java-and-spring)

## Creating a REST Web Service With Java and Spring

### 1. HTTP verbs

| HTTP VERB | URL           | DESCRIPTION                                                                                                                                                                                                                                                                                                       |
| --------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET`     | `/order`      | Obtains the list of all orders currently created in the system. If the list is successfully obtained, the list of existing orders is returned, along with an HTTP`200`(OK) status.                                                                                                                                |
| `POST`    | `/order`      | Creates a new order. This request should carry a request body that includes the data that should be associated with the newly created order. If the order is created, an HTTP`201`(Created) status is returned along with the newly created order in the response body.                                           |
| `GET`     | `/order/{id}` | Obtains the order associated with the given ID. If no order exists, an HTTP`404`(Not Found) status is returned. If the order can be found, an HTTP`200`status is returned and the response body contains the information associated with the order.                                                               |
| `PUT`     | `/order/{id}` | Updates an existing order. If no order with the given ID can be found, an HTTP`404`status is returned. If an order exists with the given ID and the request body contains valid updates to the order, the order is updated and the updated order is returned in the response body, along with an HTTP`200`status. |
| `DELETE`  | `/order/{id}` | Deletes an order with the given ID. If no order exists, an HTTP`404`status is returned. If the order exists, it is deleted, and an HTTP`204`(No Content) status is returned.                                                                                                                                      |

### 2. org.springframework.hateoas.

Spring HATEOAS provides some APIs to ease creating REST representations that follow the HATEOAS principle when working with Spring and especially Spring MVC. The core problem it tries to address is link creation and representation assembly.

#### Features

* Model classes for link, resource representation models
* Link builder API to create links pointing to Spring MVC controller methods
* Support for hypermedia formats like HAL
