Sha256: d140c2847fcf2d93187038e6d9c1e24645e0d473e6e25dea5cd88020a64461f7
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
require "delegate" require "uri" require "net/http" module Ezid # # A request to the EZID service. # # @api private # class Request < SimpleDelegator HOST = "https://ezid.cdlib.org" CHARSET = "UTF-8" CONTENT_TYPE = "text/plain" def self.execute(*args) request = new(*args) yield request if block_given? request.execute end # @param method [Symbol] the Net::HTTP constant for the request method # @param path [String] the uri path (including query string, if any) def initialize(method, path) http_method = Net::HTTP.const_get(method) uri = URI.parse([HOST, path].join) super(http_method.new(uri)) set_content_type(CONTENT_TYPE, charset: CHARSET) end # Executes the request and returns the response # @return [Ezid::Response] the response def execute http_response = Net::HTTP.start(uri.host, use_ssl: true) do |http| http.request(__getobj__) end Response.new(http_response) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ezid-client-0.7.0 | lib/ezid/request.rb |
ezid-client-0.6.0 | lib/ezid/request.rb |
ezid-client-0.5.0 | lib/ezid/request.rb |