class Served::Backends::Patron
Patron
Backend uses {Patron github.com/toland/patron} for its client. This backend does not lock the GIL and is thread safe. Use Patron
if you need high concurrency.
Public Instance Methods
delete(endpoint, id, params = {})
click to toggle source
# File lib/served/backends/patron.rb, line 34 def delete(endpoint, id, params = {}) serialize_response(::Patron::Session.new(headers: headers, timeout: timeout) .delete(template.expand(id: id, query: params, resource: endpoint).to_s)) rescue ::Patron::ConnectionFailed raise Served::HTTPClient::ConnectionFailed.new(resource) end
get(endpoint, id, params = {})
click to toggle source
# File lib/served/backends/patron.rb, line 8 def get(endpoint, id, params = {}) serialize_response(::Patron::Session.new(headers: headers, timeout: timeout) .get(template.expand(id: id, query: params, resource: endpoint).to_s)) rescue ::Patron::ConnectionFailed raise Served::HTTPClient::ConnectionFailed.new(resource) end
post(endpoint, body, params = {})
click to toggle source
# File lib/served/backends/patron.rb, line 26 def post(endpoint, body, params = {}) serialize_response(::Patron::Session.new(headers: headers, timeout: timeout) .post(template.expand(query: params, resource: endpoint).to_s, body)) rescue ::Patron::ConnectionFailed raise Served::HTTPClient::ConnectionFailed.new(resource) end
put(endpoint, id, body, params = {})
click to toggle source
# File lib/served/backends/patron.rb, line 17 def put(endpoint, id, body, params = {}) serialize_response(::Patron::Session.new(headers: headers, timeout: timeout) .put(template.expand(id: id, query: params, resource: endpoint).to_s, body)) rescue ::Patron::ConnectionFailed raise Served::HTTPClient::ConnectionFailed.new(resource) end
serialize_response(response)
click to toggle source
# File lib/served/backends/patron.rb, line 44 def serialize_response(response) OpenStruct.new(body: response.body, code: response.status) end