Sinatra now correctly returns code 404 when a page is not found. Closes #1198

This commit is contained in:
Brandon Mathis 2013-04-09 16:35:54 -05:00
parent 5ef1705a33
commit 21cd6de44a
3 changed files with 8 additions and 8 deletions

View File

@ -30,4 +30,4 @@ group :test do
gem "rspec", "~> 2.13.0"
end
gem 'sinatra', '~> 1.3.3'
gem 'sinatra', '~> 1.4.2'

View File

@ -88,10 +88,10 @@ GEM
sass (3.2.7)
sass-globbing (1.0.0)
sass (>= 3.1)
sinatra (1.3.6)
rack (~> 1.4)
rack-protection (~> 1.3)
tilt (~> 1.3, >= 1.3.3)
sinatra (1.4.2)
rack (~> 1.5, >= 1.5.2)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
slop (3.4.4)
stitch-rb (0.0.8)
stringex (1.4.0)
@ -126,7 +126,7 @@ DEPENDENCIES
rspec (~> 2.13.0)
rubypants (~> 0.2.0)
sass-globbing (~> 1.0.0)
sinatra (~> 1.3.3)
sinatra (~> 1.4.2)
stitch-rb
stringex (~> 1.4.0)
tzinfo (~> 0.3.35)

View File

@ -7,11 +7,11 @@ $root = ::File.dirname(__FILE__)
class SinatraStaticServer < Sinatra::Base
get(/.+/) do
send_sinatra_file(unescape request.path) {404}
send_sinatra_file(request.path) {404}
end
not_found do
send_sinatra_file('404.html') {"Sorry, I cannot find #{request.path}"}
send_file(File.join(File.dirname(__FILE__), 'public', '404.html'), {:status => 404})
end
def send_sinatra_file(path, &missing_file_block)