Sha256: 5b4ca29324a8575aa36bdba6fa85612060dab84afd8d24d3a75040c2c96d7664

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

# frozen_string_literal: true

module Concourse
  module Http
    class Request
      attr_reader :url, :headers, :body

      def initialize(url, headers = {}, body = nil)
        @url = url
        @headers = headers
        @body = body
      end

      def ==(other)
        other.class == self.class && other.state == state
      end

      def eql?(other)
        self == other
      end

      def hash
        state.hash
      end

      protected

      def state
        [@url, @headers, @body]
      end
    end

    def assert_successful(request, response)
      raise api_error(request, response) unless response.status < 400
    end

    private

    def api_error(request, response)
      Errors::ApiError.new(request:, response:)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
concourse.rb-0.6.0.pre.10 lib/concourse/http.rb