Skip to content

Instantly share code, notes, and snippets.

@datenimperator
Created November 12, 2012 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save datenimperator/4057694 to your computer and use it in GitHub Desktop.
Save datenimperator/4057694 to your computer and use it in GitHub Desktop.
Sinatra deferred reaction
require 'bundler/setup'
require './lib/poi_api.rb'
map '/' do
run PoiApi::App
end
source 'https://rubygems.org'
# Specify your gem's dependencies in poi_api.gemspec
gem 'rack'
gem 'sinatra'
gem 'shotgun'
require 'json'
require 'sinatra/base'
module PoiApi
class App < Sinatra::Base
configure :production, :development do
enable :logging
end
before do
content_type :json
end
get '/analytics' do
logger.info "Before"
late do
puts "Yehi!"
end
logger.info "After"
"Yes!"
end
private
def late(&block)
Thread.new do
sleep 0.5
block.call
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment