Skip to content

Instantly share code, notes, and snippets.

@jpr5
Created January 28, 2010 01:06
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 jpr5/288331 to your computer and use it in GitHub Desktop.
Save jpr5/288331 to your computer and use it in GitHub Desktop.
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