Sha256: e57e9f13cc8e48b3832a9f8ce9a3abf88077d9c5f6dc9e393b87225c7a98d73b

Contents?: true

Size: 476 Bytes

Versions: 15

Compression:

Stored size: 476 Bytes

Contents

module Roger
  module Rack
    # Listens to the "sleep" parameter and sleeps the amount of seconds specified by the parameter. There is however a maximum of 5 seconds.
    class Sleep
  
      def initialize(app)
        @app = app
      end
  
      def call(env)
        r = ::Rack::Request.new(env)
        if r.params["sleep"]
          sleeptime = [r.params["sleep"].to_i, 5].min
          sleep sleeptime
        end
        @app.call(env)
      end
  
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
roger-1.1.3 lib/roger/rack/sleep.rb
roger-1.1.2 lib/roger/rack/sleep.rb
roger-1.1.1 lib/roger/rack/sleep.rb
roger-1.1.0 lib/roger/rack/sleep.rb
roger-1.0.1 lib/roger/rack/sleep.rb
roger-1.0.0 lib/roger/rack/sleep.rb
roger-0.13.0 lib/roger/rack/sleep.rb
roger-0.12.5 lib/roger/rack/sleep.rb
roger-0.12.4 lib/roger/rack/sleep.rb
roger-0.12.3 lib/roger/rack/sleep.rb
roger-0.12.2 lib/roger/rack/sleep.rb
roger-0.12.1 lib/roger/rack/sleep.rb
roger-0.12.0 lib/roger/rack/sleep.rb
roger-0.11.0 lib/roger/rack/sleep.rb
roger-0.10.0 lib/roger/rack/sleep.rb