瘦帖请求无效

时间:2013-05-01 20:40:24

标签: ruby post sinatra thin

我有一台运行Sinatra应用程序的瘦服务器。在一个文件中,我发送一个POST请求,但它永远不会到达其路由。如果我使用bundle exec ruby myapp.rb运行相同的代码,但是当它使用bundle exec thin start -p 3000运行时,它只会与后期路由不匹配。

post '/save/:website' do |website|
    website_data = JSON.parse(request.body.read)
    puts "Saving #{website} plugin data" #never reaches here

    persister = Persister.new
    persister.update_or_persist(website_data)

    body "success"
end

这就是我宣布POST请求的方式

def send_result (path, result)
    request      = Net::HTTP::Post.new('/save/something', initheader = {'Content-Type' => 'application/json'})
    request.body = result.to_json
    response     = Net::HTTP.new('localhost', '3000').start { |http| http.request(request) }
end

以下是config.ru

# config.ru
require "./myapp"
run Sinatra::Application

我的帖子路线中从未到达puts,但是在没有thin的情况下部署时我确实达到了{{1}}。为什么这个请求不起作用?

另外,I had already opened another question about this,但这次我真的需要瘦服务器,因为我将使用Apache代理瘦。

0 个答案:

没有答案