I wonder what the difference is between the return value of a Spring Boot RestController if void shall be returned?
I can see do difference in a test in either way. It seems that even if I return void the HttpStatus.NO_CONTENT (204) is returned to the requester as well as if I use ResponseEntity<Void>.
So, when I return void from an endpoint the HttpStatus is returned anyway and it doesn't matter if I choose void or ResponseEntity<Void>?
Exactly. You would need the ResponseEntity<Void> if you want to add some headers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With