Class: Hyperion::Request

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

Overview

Immutable parsed-request value object. Phase 5 (object pooling) will redesign this with explicit reset semantics; for Phase 1 we freeze on construction to prevent accidental mutation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, path:, query_string:, http_version:, headers:, body:, peer_address: nil) ⇒ Request

Returns a new instance of Request.



10
11
12
13
14
15
16
17
18
19
# File 'lib/hyperion/request.rb', line 10

def initialize(method:, path:, query_string:, http_version:, headers:, body:, peer_address: nil)
  @method       = method
  @path         = path
  @query_string = query_string
  @http_version = http_version
  @headers      = headers.freeze
  @body         = body
  @peer_address = peer_address
  freeze
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/hyperion/request.rb', line 8

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



8
9
10
# File 'lib/hyperion/request.rb', line 8

def headers
  @headers
end

#http_versionObject (readonly)

Returns the value of attribute http_version.



8
9
10
# File 'lib/hyperion/request.rb', line 8

def http_version
  @http_version
end

#methodObject (readonly)

Returns the value of attribute method.



8
9
10
# File 'lib/hyperion/request.rb', line 8

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/hyperion/request.rb', line 8

def path
  @path
end

#peer_addressObject (readonly)

Returns the value of attribute peer_address.



8
9
10
# File 'lib/hyperion/request.rb', line 8

def peer_address
  @peer_address
end

#query_stringObject (readonly)

Returns the value of attribute query_string.



8
9
10
# File 'lib/hyperion/request.rb', line 8

def query_string
  @query_string
end

Instance Method Details

#header(name) ⇒ Object



21
22
23
# File 'lib/hyperion/request.rb', line 21

def header(name)
  @headers[name.downcase]
end