Method: Rack::Recursive#include

Defined in:
lib/rack/recursive.rb

#include(env, path) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/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