marcinadd / projecty-web

Project management software based on spring
GNU General Public License v3.0
74 stars 74 forks source link

Refactor RestController Responses from POJO to Springs ResponseEntity #71

Closed FlorianKrammel closed 3 years ago

FlorianKrammel commented 4 years ago

Currently the response of a request returns a POJO. You can do this in a more flexible way with public ResponseEntity<MyType> and return ResponseEntitiy.of(object).

ResponseEntity<T> represents the entire HTTP response. Besides the body, its API allows you to set headers and a status code to the response.

Returning just a bean is fine but doesn't give you much flexibility: In the future, if you need to add a header to the response or modify the status code, for example, you need to change the method return type.

https://stackoverflow.com/a/49673748

marcinadd commented 3 years ago

I'm back. Thanks for your response. Currently I'm studying and I've much less time for this project, but it doesn't look complicated. I will try to make a script to refactor it.

everythings13 commented 3 years ago

Hi @FlorianKrammel/ @marcinadd , lmk if some refactoring still needs to be taken up! :)