Class: Ritm::ParamEncoder
- Inherits:
-
Object
- Object
- Ritm::ParamEncoder
- Defined in:
- lib/ritm/interception/http_forwarder.rb
Overview
Forwarder that acts as a WEBrick <-> Faraday adaptor: Works this way:
1. A WEBrick request objects is received
2. The WEBrick request object is sent to the request interceptor
3. The (maybe modified) WEBrick request object is transformed into a Faraday request and sent to destination server
4. The Faraday response obtained from the server is transformed into a WEBrick response
5. The WEBrick response object is sent to the response interceptor
6. The (maybe modified) WEBrick response object is sent back to the client
Besides the possible modifications to be done by interceptors there might be automated globally configured transformations like header stripping/adding.
Instance Method Summary collapse
Instance Method Details
#decode(query) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/ritm/interception/http_forwarder.rb', line 23 def decode(query) query.split('&').each_with_object({}) do |param, params| k, v = param.split('=') params[k] = v end end |
#encode(params) ⇒ Object
18 19 20 21 |
# File 'lib/ritm/interception/http_forwarder.rb', line 18 def encode(params) pairs = params.map { |k, v| "#{k}=#{v}" } pairs.join('&') end |