I'm new to REST and I'm making simple REST application with users and articles. I wonder what's the difference between two samples below:
@GetMapping("/user/{id}")
public User getUserById(PathVariable("id") String id) {
.....
return userService.getUserById();
}
and
@GetMapping("/user/{id}")
public ResponseEntity<User> getUserById(PathVariable("id") String id) {
.....
return new ResponseEntity<> ....
}
Which one is better to use? And what's the main difference between two of them?