Rack hook which fires after the socket to the client is closed.
Ruby
Switch branches/tags
Clone or download
Latest commit b84d19b Jun 6, 2012

README.markdown

Rack After Reply

A hook for Rack apps which fires after the response has been sent, and the socket to the client has been closed.

This is the ideal time to perform delayable, non-backgroundable tasks, such as garbage collection, stats gathering, flushing logs, etc. without affecting response times at all.

Usage

Simply add your callbacks to env['rack_after_reply.callbacks'].

use Rack::ContentLength
use Rack::ContentType, 'text/plain'
run lambda { |env|
  env['rack_after_reply.callbacks'] << lambda { ... }
  [200, {}, ['hi']]
}

Support

Rack After Request works with these web servers:

To request support for other web servers, open a ticket or submit a patch.

Contributing

  • Bug reports
  • Source
  • Patches: Fork on Github, send pull request.
    • Ensure patch includes tests.
    • Leave the version alone, or bump it in a separate commit.

Copyright

Copyright (c) George Ogata. See LICENSE for details.