Class: Isomorfeus::Puppetmaster::Server::Middleware
- Inherits:
-
Object
- Object
- Isomorfeus::Puppetmaster::Server::Middleware
- Defined in:
- lib/isomorfeus/puppetmaster/server/middleware.rb
Defined Under Namespace
Classes: Counter
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #clear_error ⇒ Object
-
#initialize(app, extra_middleware = []) ⇒ Middleware
constructor
A new instance of Middleware.
- #pending_requests? ⇒ Boolean
Constructor Details
#initialize(app, extra_middleware = []) ⇒ Middleware
Returns a new instance of Middleware.
26 27 28 29 30 31 32 |
# File 'lib/isomorfeus/puppetmaster/server/middleware.rb', line 26 def initialize(app, extra_middleware = []) @app = app @extended_app = extra_middleware.inject(@app) do |ex_app, klass| klass.new(ex_app) end @counter = Counter.new end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
24 25 26 |
# File 'lib/isomorfeus/puppetmaster/server/middleware.rb', line 24 def error @error end |
Instance Method Details
#call(env) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/isomorfeus/puppetmaster/server/middleware.rb', line 42 def call(env) if env['PATH_INFO'] == '/__identify__' [200, {}, [@app.object_id.to_s]] else @counter.increment begin @extended_app.call(env) rescue Exception => err @error ||= err raise err ensure @counter.decrement end end end |
#clear_error ⇒ Object
38 39 40 |
# File 'lib/isomorfeus/puppetmaster/server/middleware.rb', line 38 def clear_error @error = nil end |
#pending_requests? ⇒ Boolean
34 35 36 |
# File 'lib/isomorfeus/puppetmaster/server/middleware.rb', line 34 def pending_requests? @counter.value.positive? end |