lib/golf/rack.rb in golf-0.1.5 vs lib/golf/rack.rb in golf-0.1.8
- old
+ new
@@ -9,13 +9,17 @@
Dir["#{resource_path}/*"].each { |x| @resources = @resources.merge({ "/#{x.split('/').last}" => File.read(x) }) }
end
def call(env)
code = "200"
+
+ if ['Gemfile','config.ru', 'Gemfile.lock'].include?(env["PATH_INFO"])
+ return [404, { 'Content-Type' => 'text/plain', 'Content-Length' => '9'}, ['not found']]
+ end
- if File.exists?(env["PATH_INFO"]) and env["PATH_INFO"] != "/"
+ if File.exists?(env["PATH_INFO"].sub('/','')) and env["PATH_INFO"] != "/"
mime = MIME_TYPES[".#{env["PATH_INFO"].split('.').last}"]
- result = File.read(env["PATH_INFO"])
+ result = File.read(env["PATH_INFO"].sub('/',''))
return [code, { 'Content-Type' => mime, 'Content-Length' => result.length.to_s}, [result]]
end
case env["PATH_INFO"]
when "/"