Sha256: 04d4ddccfa2cda856aaed0164bbb03f3708f3ad3fd2e9fd403460b43cd360963
Contents?: true
Size: 639 Bytes
Versions: 6
Compression:
Stored size: 639 Bytes
Contents
# frozen_string_literal: true module Nonnative class HTTPClient def initialize(host) @host = host end protected def get(pathname, headers = {}) with_exception do uri = URI.join(host, pathname) RestClient.get(uri.to_s, headers) end end def post(pathname, payload, headers = {}) with_exception do uri = URI.join(host, pathname) RestClient.post(uri.to_s, payload.to_json, headers) end end private attr_reader :host def with_exception yield rescue RestClient::ExceptionWithResponse => e e.response end end end
Version data entries
6 entries across 6 versions & 1 rubygems