Empty responses
In all our methods, we are set to return a JSON response, and this is because we use a RESTController. However, it is interesting to understand that if we are going to return an object, and the returning object is null, the body will be empty, so there will be no content in our response, just status. That is what is happening when we call our get service with a non-existent ID; an empty response is returned.
In the method that we declared before that returns Unit, an empty JSON object will be returned instead. If we invoke them, we will get just {}; that is what we get when we call our delete, or update methods with a non-existent ID, an empty object is returned.
But we could change the code to return no content even for the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access