Suppose you want to return a response based on the Accept header of the request.
If the Accept header is application/json you want to return a JSON response and if the Accept header is application/xml you want to return an XML response.
You can use the isAccepted(MediaType) of the ServerRequestHeaders class to check if the value of the request header Accept is equal to the specified media type.
The method returns true if the media type is defined for the request header Accept and false if not.