A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Server/Middleware below:

Middleware – Documentation for teamcapybara/capybara (master) – RubyDoc.info

Class: Capybara::Server::Middleware Private
Inherits:
Object show all
Defined in:
lib/capybara/server/middleware.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Counter

Instance Attribute Summary collapse Instance Method Summary collapse Constructor Details #initialize(app, server_errors, extra_middleware = []) ⇒ Middleware

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Middleware.

31
32
33
34
35
36
37
38
# File 'lib/capybara/server/middleware.rb', line 31

def initialize(app, server_errors,  = [])
  @app = app
  @extended_app = .inject(@app) do |ex_app, klass|
    klass.new(ex_app)
  end
  @counter = Counter.new
  @server_errors = server_errors
end
Instance Attribute Details #error ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

29
30
31
# File 'lib/capybara/server/middleware.rb', line 29

def error
  @error
end
Instance Method Details #call(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/capybara/server/middleware.rb', line 52

def call(env)
  if env['PATH_INFO'] == '/__identify__'
    [200, {}, [@app.object_id.to_s]]
  else
    request_uri = env['REQUEST_URI']
    @counter.increment(request_uri)

    begin
      @extended_app.call(env)
    rescue *@server_errors => e
      @error ||= e
      raise e
    ensure
      @counter.decrement(request_uri)
    end
  end
end
#clear_error ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

48
49
50
# File 'lib/capybara/server/middleware.rb', line 48

def clear_error
  @error = nil
end
#pending_requests ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

40
41
42
# File 'lib/capybara/server/middleware.rb', line 40

def pending_requests
  @counter.value
end
#pending_requests? ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

44
45
46
# File 'lib/capybara/server/middleware.rb', line 44

def pending_requests?
  @counter.positive?
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4