Class: Rack::Audit
- Inherits:
-
Object
- Object
- Rack::Audit
- Defined in:
- lib/rack-audit/version.rb,
lib/rack-audit.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, name, uri) ⇒ Audit
constructor
A new instance of Audit.
Constructor Details
#initialize(app, name, uri) ⇒ Audit
Returns a new instance of Audit.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rack-audit.rb', line 13 def initialize(app, name, uri) @app = app @queue = Queue.new @uri = URI(uri) @host = @uri.host @port = @uri.port @name = name @consumer = Thread.new do while true do body = @queue.pop begin post(@uri, body) rescue => e STDERR.puts e.inspect end end end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
12 13 14 |
# File 'lib/rack-audit.rb', line 12 def host @host end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/rack-audit.rb', line 12 def name @name end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
12 13 14 |
# File 'lib/rack-audit.rb', line 12 def port @port end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
12 13 14 |
# File 'lib/rack-audit.rb', line 12 def queue @queue end |
Instance Method Details
#call(env) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rack-audit.rb', line 33 def call(env) uuid = UUIDTools::UUID.random_create.to_s log_request(uuid, env) response = @app.call(env) log_response(uuid, response) response end |