Hi Jeremy,
As I understand it (and as we previously discussed), the way to check headers on requests is to use a header matcher.
Now, in my app's error block, I'd like to render HTML for browsers and return JSON (or an empty body) for non-browsers.
Here's a sample of what I'm talking about:
error do |e|
if e.is_a?(Sequel::NoMatchingRow)
response.status = 404
# if request.accept?('text/html')
# view 'not_found'
# else
# JSON.generate({message: "Not Found"})
# end
end
end
This doesn't currently work since request has no accept? method. Is there a good alternative here?
Thanks!
Andrew