Sinatra::RunLater
A simple way to do real after filtering with Sinatra.
A gem-ed up version of a slight modification of this version that cleans up nicely when used through rackup
and ctrl-c
is sent.
Installation
Add this line to your application's Gemfile:
gem 'sinatra-run-later', :require => 'sinatra/run-later'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sinatra-run-later
Usage
Anywhere in your Sinatra app, just drop in something like this:
get '/' do
run_later do
# some task that you don't want to block.
end
"Hello World"
end
If you're running a modular style app, just add the helpers like so:
class YourApp
configure do
helpers Sinatra::RunLater::InstanceMethods
end
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request