Class: JSONAPI::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/easy/jsonapi/request.rb,
lib/easy/jsonapi/request/query_param_collection.rb,
lib/easy/jsonapi/request/query_param_collection/page_param.rb,
lib/easy/jsonapi/request/query_param_collection/sort_param.rb,
lib/easy/jsonapi/request/query_param_collection/query_param.rb,
lib/easy/jsonapi/request/query_param_collection/fields_param.rb,
lib/easy/jsonapi/request/query_param_collection/filter_param.rb,
lib/easy/jsonapi/request/query_param_collection/include_param.rb,
lib/easy/jsonapi/request/query_param_collection/filter_param/filter.rb,
lib/easy/jsonapi/request/query_param_collection/fields_param/fieldset.rb

Overview

Contains all objects relating to a HTTP request

Defined Under Namespace

Classes: QueryParamCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, query_param_collection, header_collection, document) ⇒ Request

Returns a new instance of Request.

Parameters:

  • env

    The rack envirornment hash

  • query_param_collection (QueryParamCollection)

    The already initialized QueryParamCollection class

  • header_collection (HeaderCollection)

    The already initialized HeaderCollection class

  • document (Document)

    The already initialized Document class



12
13
14
15
16
17
18
19
20
21
22
23
24
# 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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/easy/jsonapi/request.rb', line 6

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



6
7
8
# File 'lib/easy/jsonapi/request.rb', line 6

def headers
  @headers
end

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/easy/jsonapi/request.rb', line 6

def host
  @host
end

#http_methodObject (readonly)

Returns the value of attribute http_method.



6
7
8
# File 'lib/easy/jsonapi/request.rb', line 6

def http_method
  @http_method
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/easy/jsonapi/request.rb', line 6

def params
  @params
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/easy/jsonapi/request.rb', line 6

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



6
7
8
# File 'lib/easy/jsonapi/request.rb', line 6

def port
  @port
end

#query_stringObject (readonly)

Returns the value of attribute query_string.



6
7
8
# File 'lib/easy/jsonapi/request.rb', line 6

def query_string
  @query_string
end

Instance Method Details

#to_sObject

Simple representation of a request object.



27
28
29
30
31
32
33
34
35
36
37
38
# 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