Class: MLserver::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/MLserver/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers: {}, request:, data: "", client:) ⇒ Request

Returns a new instance of Request.



3
4
5
6
7
8
9
10
# File 'lib/MLserver/request.rb', line 3

def initialize(headers: {}, request:, data: "", client:)
  @headers = headers
  @request = request
  @data = data
  @client = client

  @request_split = @request.split(" ")
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



29
30
31
# File 'lib/MLserver/request.rb', line 29

def data
  @data
end

#headersObject (readonly)

Returns the value of attribute headers.



29
30
31
# File 'lib/MLserver/request.rb', line 29

def headers
  @headers
end

#requestObject (readonly)

Returns the value of attribute request.



29
30
31
# File 'lib/MLserver/request.rb', line 29

def request
  @request
end

Instance Method Details

#httpverObject



20
21
22
# File 'lib/MLserver/request.rb', line 20

def httpver
  @request_split[2]
end

#methodObject



12
13
14
# File 'lib/MLserver/request.rb', line 12

def method
  @request_split[0].upcase
end

#pathObject



16
17
18
# File 'lib/MLserver/request.rb', line 16

def path
  @request_split[1]
end

#respond(response) ⇒ Object



24
25
26
27
# File 'lib/MLserver/request.rb', line 24

def respond(response)
  MLserver.settings.logger.log_traffic @client.peeraddr[2], :outgoing, "#{response.httpver} #{response.status}"
  @client.puts response.to_s
end