Class: Rack::Recursive
- Inherits:
 - 
      Object
      
        
- Object
 - Rack::Recursive
 
 - Defined in:
 - rack/rack/recursive.rb
 
Overview
Rack::Recursive allows applications called down the chain to include data
from other applications (by using
rack['rack.recursive.include'][...] or raise a ForwardRequest
to redirect internally.
Instance Method Summary (collapse)
- - (void) _call(env)
 - - (void) call(env)
 - - (void) include(env, path)
 - 
  
    
      - (Recursive) initialize(app) 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Recursive.
 
Constructor Details
- (Recursive) initialize(app)
Returns a new instance of Recursive
      33 34 35  | 
    
      # File 'rack/rack/recursive.rb', line 33 def initialize(app) @app = app end  | 
  
Instance Method Details
- (void) _call(env)
      41 42 43 44 45 46  | 
    
      # File 'rack/rack/recursive.rb', line 41 def _call(env) @script_name = env["SCRIPT_NAME"] @app.call(env.merge('rack.recursive.include' => method(:include))) rescue ForwardRequest => req call(env.merge(req.env)) end  | 
  
- (void) call(env)
      37 38 39  | 
    
      # File 'rack/rack/recursive.rb', line 37 def call(env) dup._call(env) end  | 
  
- (void) include(env, path)
      48 49 50 51 52 53 54 55 56 57 58 59  | 
    
      # File 'rack/rack/recursive.rb', line 48 def include(env, path) unless path.index(@script_name) == 0 && (path[@script_name.size] == ?/ || path[@script_name.size].nil?) raise ArgumentError, "can only include below #{@script_name}, not #{path}" end env = env.merge("PATH_INFO" => path, "SCRIPT_NAME" => @script_name, "REQUEST_METHOD" => "GET", "CONTENT_LENGTH" => "0", "CONTENT_TYPE" => "", "rack.input" => StringIO.new("")) @app.call(env) end  |