Class: Hateoas::MediaType::Request

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hateoas.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, media_type) ⇒ Request

Returns a new instance of Request.



40
41
42
43
# File 'lib/hateoas.rb', line 40

def initialize(url, media_type)
  @uri = URI(url)
  @media_type = media_type
end

Instance Method Details

#getObject



45
46
47
48
49
50
# File 'lib/hateoas.rb', line 45

def get
  req = Net::HTTP::Get.new(request_uri)
  req['Accept'] = @media_type

  Net::HTTP.start(hostname, port) {|http| http.request(req) }.body
end