我确实构造了 RestClient 包装器
require 'json'
require 'rest_client'
$url_common_part = 'http://host:port/cgi-bin/cgi_script'
class Grabber
def initialize
@site = RestClient::Resource.new($url_common_part)
end
def post ( path, params )
site_and_path = @site["#{path}"]
payload = params.to_json
puts "\n", payload
response = site_and_path.post (
payload,
headers = {
'MY-HEADER' => 'MY-VALUE',
'content_type' => 'json',
'accept' => 'json'
}
)
return response
end
end
并且 get 效果很好,但是 post 给出了错误syntax error, unexpected ',', expecting ')' (SyntaxError)
有人可以建议我做错了什么吗?