Class: Gloo::WebSvr::RequestParams
- Inherits:
-
Object
- Object
- Gloo::WebSvr::RequestParams
- Defined in:
- lib/gloo/web_svr/request_params.rb
Instance Attribute Summary collapse
-
#body_params ⇒ Object
readonly
Returns the value of attribute body_params.
-
#id ⇒ Object
Returns the value of attribute id.
-
#query_params ⇒ Object
readonly
Returns the value of attribute query_params.
-
#route_params ⇒ Object
Returns the value of attribute route_params.
Instance Method Summary collapse
-
#get_body_method_override(orig_method) ⇒ Object
Check the body to see if there is a PATCH or a PUT in the method override.
-
#init_body_params(body) ⇒ Object
Detect the parameters from the body of the request.
-
#init_query_params(query_string) ⇒ Object
Detect the parameters from query string.
-
#initialize(log) ⇒ RequestParams
constructor
Set up the web server.
-
#log_id_keys ⇒ Object
Write the id and route params to the log.
-
#log_params ⇒ Object
Write the querey and body params to the log.
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_params ⇒ Object (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 |
#id ⇒ Object
Returns the value of attribute id.
17 18 19 |
# File 'lib/gloo/web_svr/request_params.rb', line 17 def id @id end |
#query_params ⇒ Object (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_params ⇒ Object
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_keys ⇒ Object
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_params ⇒ Object
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 |