由於辛特拉是一個機架的應用程序,我認爲它可以使用機架的方式:如何使用Sinatra服務500頁?
get '/' do
result = true
if result
['200', {'Content-Type' => 'application/json'}, [{result:true}.to_ json]]
else
binding.pry
['500', {'Content-Type' => 'application/json'}, [{result:false}.to _json]]
end
end
它不工作,它送花兒給人返回500
頁面,該變量是true
或false
這實際上會產生一個SyntaxError在這種情況下:'語法錯誤:(IRB):2:語法錯誤,意想不到的tIDENTIFIER,期待']'而不是運行時錯誤,所以服務器甚至不會啓動,而不是產生'500'錯誤。 – matt 2013-05-17 21:43:30