Class: Foobara::CommandConnectors::Http::Rack::Request

Inherits:
Foobara::CommandConnectors::Http::Request show all
Defined in:
foobara-rack-connector-0.0.10/lib/foobara/command_connectors/http/rack/request.rb

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary collapse

Attributes inherited from Foobara::CommandConnectors::Http::Request

#body, #cookies, #headers, #host, #method, #path, #port, #prefix, #query_string, #remote_ip, #response_headers, #scheme

Attributes inherited from Foobara::CommandConnector::Request

#action, #command, #command_class, #command_connector, #error, #full_command_name, #inputs, #response, #serializers

Instance Method Summary collapse

Methods inherited from Foobara::CommandConnectors::Http::Request

#action, #argument, #full_command_name, #inputs, #parsed_body, #parsed_query_string, #prefixless_path, #set_action_and_command_name, #set_response_header, #url

Methods inherited from Foobara::CommandConnector::Request

#error_collection, #outcome, #response_body, #result, #serializer, #success?

Methods included from TruncatedInspect

#inspect, truncating

Constructor Details

#initialize(env, prefix: nil) ⇒ Request

Returns a new instance of Request.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'foobara-rack-connector-0.0.10/lib/foobara/command_connectors/http/rack/request.rb', line 8

def initialize(env, prefix: nil)
  self.env = env

  scheme = if env["HTTP_X_FORWARDED_PROTO"] == "https" || env["HTTPS"] == "on"
             "https"
           else
             "http"
           end

  super(
    scheme:,
    host: env["SERVER_NAME"],
    port: env["SERVER_PORT"],
    path: env["PATH_INFO"],
    query_string: env["QUERY_STRING"],
    method: env["REQUEST_METHOD"],
    # TODO: should we delay this read instead of eager-loading this?
    body: env["rack.input"]&.read || "",
    headers: extract_headers,
    cookies: ::Rack::Utils.parse_cookies(env),
    remote_ip: env["REMOTE_ADDR"],
    prefix:
  )
end

Instance Attribute Details

#envObject

Returns the value of attribute env.



6
7
8
# File 'foobara-rack-connector-0.0.10/lib/foobara/command_connectors/http/rack/request.rb', line 6

def env
  @env
end