class Served::Backends::HTTParty

HTTParty Backend uses the {github.com/jnunemaker/httparty HTTParty} client

Public Instance Methods

delete(endpoint, id, params = {}) click to toggle source
# File lib/served/backends/httparty.rb, line 38
def delete(endpoint, id, params = {})
  ::HTTParty.delete(template.expand(id:       id,
                                    query:    params,
                                    resource: endpoint).to_s,
                    headers: headers,
                    timeout: timeout)
rescue Errno::ECONNREFUSED
  raise Served::HTTPClient::ConnectionFailed.new(resource)
end
get(endpoint, id, params = {}) click to toggle source
# File lib/served/backends/httparty.rb, line 8
def get(endpoint, id, params = {})
  ::HTTParty.get(template.expand(id:       id,
                                 query:    params,
                                 resource: endpoint).to_s,
                 headers: headers,
                 timeout: timeout)
rescue Errno::ECONNREFUSED
  raise Served::HTTPClient::ConnectionFailed.new(resource)
end
post(endpoint, body, params = {}) click to toggle source
# File lib/served/backends/httparty.rb, line 29
def post(endpoint, body, params = {})
  ::HTTParty.post(template.expand(query: params, resource: endpoint).to_s,
                  body: body,
                  headers: headers,
                  timeout: timeout)
rescue Errno::ECONNREFUSED
  raise Served::HTTPClient::ConnectionFailed.new(resource)
end
put(endpoint, id, body, params = {}) click to toggle source
# File lib/served/backends/httparty.rb, line 18
def put(endpoint, id, body, params = {})
  ::HTTParty.put(template.expand(id:       id,
                                 query:    params,
                                 resource: endpoint).to_s,
                 body:    body,
                 headers: headers,
                 timeout: timeout)
rescue Errno::ECONNREFUSED
  raise Served::HTTPClient::ConnectionFailed.new(resource)
end