trebol-ecommerce / trebol-backend-monolith

Monolithic eCommerce backend web application that exposes a RESTful API.
MIT License
16 stars 21 forks source link

Improve API readbility in RestControllers #18

Closed bglamadrid closed 3 years ago

bglamadrid commented 3 years ago

Using ResponseEntity is a great way to write controllers down as if they were API documentation, with declared HTTP response codes.

bglamadrid commented 3 years ago

It is a cleaner practice to annotate with @ResponseStatus and only use ResponseEntity for uncommon status codes that require a bit more complex preparation, such as the 301 SEE_OTHER code that should include a Location header with a valid URI.