Skip to content

Instantly share code, notes, and snippets.

@jpr5
Created Jan 28, 2010
Embed
What would you like to do?
Script demonstrating that latest Sinatra doesn't invoke before hooks on static files
`git clone git://github.com/sinatra/sinatra.git` unless File.exists?('sinatra')
`mkdir -p public`
`touch public/favicon.ico`
$: << 'sinatra/lib'
require 'rack'
require 'sinatra/base'
class Server < ::Sinatra::Base
set :public, Dir.pwd + '/public'; enable :static
get "/" do "hi" end
before { puts "dongs" }
after { puts "balls" }
end
run Server
$ rackup -p 9000
dongs
balls
127.0.0.1 - - [27/Jan/2010 17:33:21] "GET / HTTP/1.1" 200 2 0.0021
balls
127.0.0.1 - - [27/Jan/2010 17:33:21] "GET /favicon.ico HTTP/1.1" 200 - 0.0023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment