We have an API endpoint called by a legacy client with Accept: */*
(1), in which case it should return JSON. This API also needs to respond differently to turbo_stream requests. How can these be differentiated?
In the following snippet, the legacy client is sent the turbo_stream response because */*
matches every mime type (including turbo_stream), which is not what we want:
respond_to do |format|
format.turbo_stream
format.any { render ... }
end
(1) No header is actually sent, which is interpreted as Accept: */*
.