在 Sinatra 中是否可以将 content_type 'application/json'
设为默认值?因为我正在构建一个 REST API。
最佳答案
当然,将 content_type
添加到 before
回调中:
class MyApp < Sinatra::Base
before do
content_type 'application/json'
end
...
end
Sinatra 1.1在过滤器之前引入模式匹配:
before '/admin/*' do
check_logged_in
end
https://stackoverflow.com/questions/4632122/