Sha256: 27a282c1d457f5b513f6e4695633b5709c3daa33cf445b53b15b739e9fb6f41a
Contents?: true
Size: 1022 Bytes
Versions: 3
Compression:
Stored size: 1022 Bytes
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.4.2 | lib/ezid/request.rb |
ezid-client-0.4.1 | lib/ezid/request.rb |
ezid-client-0.4.0 | lib/ezid/request.rb |