class JSONAPI::Request

Contains all objects relating to a HTTP request

Attributes

body[R]
headers[R]
host[R]
http_method[R]
params[R]
path[R]
port[R]
query_string[R]

Public Class Methods

new(env, query_param_collection, header_collection, document) click to toggle source

@param env The rack envirornment hash @param query_param_collection [QueryParamCollection] The already initialized QueryParamCollection class @param header_collection [HeaderCollection] The already initialized HeaderCollection class @param document [Document] The already initialized Document class

# File lib/easy/jsonapi/request.rb, line 12
def initialize(env, query_param_collection, header_collection, document)
  # from env hash
  @path = env['REQUEST_PATH']
  @http_method = env['REQUEST_METHOD']
  @host = env['SERVER_NAME']
  @port = env['SERVER_PORT'].to_i
  @query_string = env['QUERY_STRING']

  # parsed objects
  @params = query_param_collection
  @headers = header_collection
  @body = document
end

Public Instance Methods

to_s() click to toggle source

Simple representation of a request object.

# File lib/easy/jsonapi/request.rb, line 27
def to_s
  "Quick Access Methods:\n\n" \
    "\tpath: #{@path}\n" \
    "\thttp: #{@http}\n" \
    "\thost: #{@host}\n" \
    "\tport: #{@port}\n" \
    "\tquery_string: #{@query_string}\n\n" \
  "Accessing main sections of request:\n\n" \
    "\tparams: #{@params}\n" \
    "\theaders: #{@headers}\n" \
    "\tbody: #{@body}" \
end