def call(env)
strip_path_prefix(env) if @path_prefix
path = env['PATH_INFO'] ? env['PATH_INFO'].chomp('/') : ""
cached_path = (path.empty? ? 'index' : path) + '.html'
Merb.logger.info "Request: #{path}"
if file_exist?(path) && env['REQUEST_METHOD'] =~ /GET|HEAD/
serve_static(env)
elsif file_exist?(cached_path) && env['REQUEST_METHOD'] =~ /GET|HEAD/
env['PATH_INFO'] = cached_path
serve_static(env)
else
if path =~ /favicon\.ico/
return [404, {"Content-Type"=>"text/html"}, "404 Not Found."]
end
begin
controller = ::Merb::Dispatcher.handle(env)
rescue Object => e
return [500, {"Content-Type"=>"text/html"}, e.message + "<br/>" + e.backtrace.join("<br/>")]
end
Merb.logger.info "\n\n"
Merb.logger.flush
[controller.status, controller.headers, controller.body]
end
end