Set default content_type for Sinatra

Is it possible to make content_type 'application/json' default value in Sinatra? because i write api.

+44
json content-type ruby sinatra
Jan 08 2018-11-11T00:
source share
1 answer

Of course, 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 
+68
Jan 08 '11 at 3:14
source share



All Articles