httparty使用 timeout (using timeout in httparty)
访问量: 6887
2018-7-25 更新:
贼简单: 参考: https://github.com/jnunemaker/httparty/issues/335
GET方式:
response = HTTParty.get('http://www.firebase.io', timeout: 10)
POST方式:
HTTParty.post('http://www.firebase.io', body: params, timeout: 10)
这个例子是把httparty 放到某个class中. an example:
1 # -*- encoding : utf-8 -*- 2 class StaticFilesController < ApplicationController 3 include HTTParty 4 default_timeout 3 11 12 def get_generator_plans 13 self.class.get 'some/url' 14 end 15 end