Class: Gloo::WebSvr::RequestParams

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo/web_svr/request_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log) ⇒ RequestParams

Set up the web server.



27
28
29
# File 'lib/gloo/web_svr/request_params.rb', line 27

def initialize( log )
  @log = log
end

Instance Attribute Details

#body_paramsObject (readonly)

Returns the value of attribute body_params.



18
19
20
# File 'lib/gloo/web_svr/request_params.rb', line 18

def body_params
  @body_params
end

#idObject

Returns the value of attribute id.



17
18
19
# File 'lib/gloo/web_svr/request_params.rb', line 17

def id
  @id
end

#query_paramsObject (readonly)

Returns the value of attribute query_params.



18
19
20
# File 'lib/gloo/web_svr/request_params.rb', line 18

def query_params
  @query_params
end

#route_paramsObject

Returns the value of attribute route_params.



17
18
19
# File 'lib/gloo/web_svr/request_params.rb', line 17

def route_params
  @route_params
end

Instance Method Details

#get_body_method_override(orig_method) ⇒ Object

Check the body to see if there is a PATCH or a PUT in the method override.



67
68
69
70
71
72
# File 'lib/gloo/web_svr/request_params.rb', line 67

def get_body_method_override orig_method
  if @body_params[ '_method' ]
    return @body_params[ '_method' ].upcase
  end
  return orig_method
end

#init_body_params(body) ⇒ Object

Detect the parameters from the body of the request.



50
51
52
53
54
55
56
# File 'lib/gloo/web_svr/request_params.rb', line 50

def init_body_params body
  if body
    @body_params = Rack::Utils.parse_query body
  else
    @body_params = {} 
  end
end

#init_query_params(query_string) ⇒ Object

Detect the parameters from query string.



39
40
41
42
43
44
45
# File 'lib/gloo/web_svr/request_params.rb', line 39

def init_query_params query_string
  if query_string
    @query_params = Rack::Utils.parse_query( query_string )
  else
    @query_params = {} 
  end
end

#log_id_keysObject

Write the id and route params to the log.



92
93
94
95
96
97
98
99
100
# File 'lib/gloo/web_svr/request_params.rb', line 92

def log_id_keys
  return unless @log

  @log.info "--- ID Parameter: #{@id}" if @id

  if @route_params && ! @route_params.empty?
    @log.info "--- Route Parameters: #{@route_params}"
  end
end

#log_paramsObject

Write the querey and body params to the log.



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/gloo/web_svr/request_params.rb', line 77

def log_params
  return unless @log

  if @query_params && ! @query_params.empty?
    @log.info "--- Query Parameters: #{@query_params}" 
  end

  if @body_params && ! @body_params.empty?
    @log.info "--- Body Parameters: #{@body_params}"
  end
end