rack.git  about / heads / tags
a modular Ruby webserver interface
blob f1e2e1f3000a5cf9c21d27a29184d19b52296d32 843 bytes (raw)
$ git show rack.io:test/rackup/config.ru	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
require "#{File.dirname(__FILE__)}/../testrequest"

$stderr = File.open("#{File.dirname(__FILE__)}/log_output", "w")

class EnvMiddleware
  def initialize(app)
    @app = app
  end

  def call(env)
    # provides a way to test that lint is present
    if env["PATH_INFO"] == "/broken_lint"
      return [200, {}, ["Broken Lint"]]
    # provides a way to kill the process without knowing the pid
    elsif env["PATH_INFO"] == "/die"
      exit!
    end

    env["test.$DEBUG"]      = $DEBUG
    env["test.$EVAL"]       = BUKKIT if defined?(BUKKIT)
    env["test.$VERBOSE"]    = $VERBOSE
    env["test.$LOAD_PATH"]  = $LOAD_PATH
    env["test.stderr"]      = File.expand_path($stderr.path)
    env["test.Ping"]        = defined?(Ping)
    env["test.pid"]         = Process.pid
    @app.call(env)
  end
end

use EnvMiddleware
run TestRequest.new

git clone https://yhbt.net/rack.git