Skip to content

JARADES-M/REST-API-Level-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTfull API Level 4

Still Under Development

HATEOAS * Semantic HTTP Verbs * Resources / URI * Caching * OAS / Swagger

You can run the application using Maven wrapper

$ ./mvnw clean spring-boot:run

Installed Maven

$ mvn clean spring-boot:run

Or using the 'Run' command of your IDE.

Example of a RESTfull Resquest/Response

GET Request:

http://{host}/employees/1

JSON Response:

{
  "id": 1,
  "name": "Bilbo Baggins",
  "role": "burglar",
  "_links": {
    "self": {
      "href": "http://localhost:8080/employees/1"
    },
    "employees": {
      "href": "http://localhost:8080/employees"
    }
  }
}

The interface ResourceAssembler, helps to implement HATEOAS using links and the HAL format.

@Component
public class EmployeeResourceAssembler implements ResourceAssembler<Employee, Resource<Employee>> {

    @Override
    public Resource<Employee> toResource(Employee employee) {
        return new Resource<Employee>(employee,
                linkTo(methodOn(EmployeeController.class).one(employee.getId())).withSelfRel(),
                linkTo(methodOn(EmployeeController.class).all()).withRel("employee")
        );
    }
}

Me:

References:

About

Example of an implementation o a RestFull API Level 3. HTTP Verbs + Resources + HATEOAS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages