Class: Ondotori::WebAPI::HttpWebAccess
Instance Method Summary
collapse
Methods inherited from WebAccess
#initialize
Instance Method Details
#access(uri, params) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/ondotori/webapi/httpwebaccess.rb', line 14
def access(uri, params)
web_uri = URI.parse(uri)
http = Net::HTTP.new(web_uri.host, web_uri.port)
http.use_ssl = (web_uri.scheme == "https")
response = http.request_post(web_uri.path, params.to_json, )
case response
when Net::HTTPSuccess
response
when Net::HTTPClientError, Net::HTTPServerError
response
else
raise Ondotori::WebAPI::Api::Errors::HttpAccessError.new("#{response.message}", "#{response.code}", 9995)
end
end
|
10
11
12
|
# File 'lib/ondotori/webapi/httpwebaccess.rb', line 10
def
{ "Content-Type" => "application/json", "X-HTTP-Method-Override" => "GET" }
end
|