In Sinatra, is it possible to make content_type 'application/json'
the default? cause I'm writing an api.
Sure, add content_type
to the before
callback:
class MyApp < Sinatra::Base
before do
content_type 'application/json'
end
...
end
Sinatra 1.1 introduces pattern-matching before filters:
before '/admin/*' do
check_logged_in
end