Class: Faraday::Request
- Extended by:
 - AutoloadHelper, MiddlewareRegistry
 
- Defined in:
 - lib/puppet/feature/faraday/request.rb,
lib/puppet/feature/faraday/autoload.rb 
Overview
Used to setup urls, params, headers, and the request body in a sane manner.
@connection.post do |req|
  req.url 'http://localhost', 'a' => '1' # 'http://localhost?a=1'
  req.headers['b'] = '2' # Header
  req.params['c']  = '3' # GET Param
  req['b']         = '2' # also Header
  req.body = 'abc'
end
  Defined Under Namespace
Classes: Authorization, BasicAuthentication, Instrumentation, Multipart, Retry, TokenAuthentication, UrlEncoded
Instance Attribute Summary collapse
- 
  
    
      #body  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute body.
 - 
  
    
      #headers  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute headers.
 - 
  
    
      #method  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute method.
 - 
  
    
      #options  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute options.
 - 
  
    
      #params  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute params.
 - 
  
    
      #path  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute path.
 
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
 - #[]=(key, value) ⇒ Object
 - 
  
    
      #to_env(connection)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
ENV Keys :method - a symbolized request method (:get, :post) :body - the request body that will eventually be converted to a string.
 - #url(path, params = nil) ⇒ Object
 
Methods included from MiddlewareRegistry
fetch_middleware, load_middleware, lookup_middleware, middleware_mutex, register_middleware
Methods included from AutoloadHelper
all_loaded_constants, autoload_all, load_autoloaded_constants
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
      12 13 14  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 12 def body @body end  | 
  
#headers ⇒ Object
Returns the value of attribute headers
      12 13 14  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 12 def headers @headers end  | 
  
#method ⇒ Object
Returns the value of attribute method
      12 13 14  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 12 def method @method end  | 
  
#options ⇒ Object
Returns the value of attribute options
      12 13 14  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 12 def @options end  | 
  
#params ⇒ Object
Returns the value of attribute params
      12 13 14  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 12 def params @params end  | 
  
#path ⇒ Object
Returns the value of attribute path
      12 13 14  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 12 def path @path end  | 
  
Class Method Details
.create(request_method) ⇒ Object
      24 25 26 27 28  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 24 def self.create(request_method) new(request_method).tap do |request| yield(request) if block_given? end end  | 
  
Instance Method Details
#[](key) ⇒ Object
      62 63 64  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 62 def [](key) headers[key] end  | 
  
#[]=(key, value) ⇒ Object
      66 67 68  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 66 def []=(key, value) headers[key] = value end  | 
  
#to_env(connection) ⇒ Object
ENV Keys :method - a symbolized request method (:get, :post) :body - the request body that will eventually be converted to a string. :url - URI instance for the current request. :status - HTTP response status code :request_headers - hash of HTTP Headers to be sent to the server :response_headers - Hash of HTTP headers from the server :parallel_manager - sent if the connection is in parallel mode :request - Hash of options for configuring the request.
:timeout      - open/read timeout Integer in seconds
:open_timeout - read timeout Integer in seconds
:proxy        - Hash of proxy options
  :uri        - Proxy Server URI
  :user       - Proxy server username
  :password   - Proxy server password
:ssl - Hash of options for configuring SSL requests.
      86 87 88 89  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 86 def to_env(connection) Env.new(method, body, connection.build_exclusive_url(path, params), , headers, connection.ssl, connection.parallel_manager) end  | 
  
#url(path, params = nil) ⇒ Object
      48 49 50 51 52 53 54 55 56 57 58 59 60  | 
    
      # File 'lib/puppet/feature/faraday/request.rb', line 48 def url(path, params = nil) if path.respond_to? :query if query = path.query path = path.dup path.query = nil end else path, query = path.split('?', 2) end self.path = path self.params.merge_query query, .params_encoder self.params.update(params) if params end  |