0
# for OSX compatibility
0
Socket.do_not_reverse_lookup = true
0
+ def initialize(options={})
0
+ @static_server = ::Rack::File.new(::File.join(Merb.root, "public"))
0
+ path = env['PATH_INFO'].chomp('/')
0
+ cached_path = (path.empty? ? 'index' : path) + '.html'
0
- def start(host, ports)
0
- start_server(host, port)
0
- trap("INT"){ Merb.stop }
0
+ if file_exist?(path) # Serve the file if it's there
0
+ elsif file_exist?(cached_path) # Serve the page cache if it's there
0
+ env['PATH_INFO'] = cached_path
0
+ else # No static file, let Merb handle it
0
+ # TODO refactor this in File#can_serve?(path) ??
0
+ full_path = ::File.join(@static_server.root, ::Rack::Utils.unescape(path))
0
+ ::File.file?(full_path) && ::File.readable?(full_path)
0
- def initialize(options={})
0
- @root = options[:root] || Dir.pwd
0
- @env = options[:environment] || 'development'
0
- @static_server = Rack::File.new(::File.join(Merb.root, "public"))
0
- ENV['RAILS_ENV'] = @env
0
+ @static_server.call(env)
0
+ def serve_dynamic(env)
0
+ request = RequestWrapper.new(env)
0
+ response = StringIO.new
0
+ controller, action = ::Merb::Dispatcher.handle(request, response)
0
+ return [500, {"Content-Type"=>"text/html"}, "Internal Server Error"]
0
+ [controller.status, controller.headers, controller.body]
0
- require "#{@root}/config/environment"
0
- # TODO refactor this in File#can_serve?(path) ??
0
- full_path = ::File.join(@static_server.root, Utils.unescape(path))
0
- ::File.file?(full_path) && ::File.readable?(full_path)
0
- @static_server.call(env)
0
- def serve_dynamic(env)
0
- request = RequestWrapper.new(env)
0
- response = StringIO.new
0
- controller, action = ::Merb::Dispatcher.handle(request, response)
0
- return [500, {"Content-Type"=>"text/html"}, "Internal Server Error"]
0
- [controller.status, controller.headers, controller.body]
0
- path = env['PATH_INFO'].chomp('/')
0
- cached_path = (path.empty? ? 'index' : path) + 'html'
0
- if file_exist?(path) # Serve the file if it's there
0
- elsif file_exist?(cached_path) # Serve the page cache if it's there
0
- env['PATH_INFO'] = cached_path
0
- else # No static file, let Merb handle it
0
\ No newline at end of file
0
\ No newline at end of file
Comments
No one has commented yet.