I want my spring boot application only to return response in json format.
Spring boot decides the response type according to request accept
header. It deserializes response according to the header (json, xml or html)
I know that my client works with json only. So there is no point for me to respond in xml and html formats.
If I am capable of returning xml and html responses, I expect my client to receive json response as well. Why do I have to prepare the response in xml, why don't my client is unable to understand json messages?
You may think that you have more than one client, you save work from all of them but I have more than one API as well so I also need to save work from myself as well...
Assume the client is also a spring boot application. There is no point sending xml
or json
responses since both will deserialize to the same model object. So why is it my duty to prepare html
or xml
response? I want my application to be as simple as possible and these different response formats bring pointless complexity in my application. Or is it so?
So how can I configure this in spring boot?
Thanks in advance.
I want to disable xml and html responses. Simply return 404
when these kind of requests are received or inform the client that this server only supports json
response type (actually there should be a specific status code for this situation)
Or since HTTP/1.1
servers are allowed to return responses which are not acceptable according to the accept
headers sent in the request, ignore the accept
header and return json
response. (https://stackoverflow.com/a/15027174/17968709)
So how can I configure this in spring boot?