Class: Mongrel::Rails::RailsHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/quick_serve/rails/ext/mongrel.rb

Instance Method Summary collapse

Instance Method Details

#original_processObject



6
# File 'lib/quick_serve/rails/ext/mongrel.rb', line 6

alias_method :original_process, :process

#process(request, response) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/quick_serve/rails/ext/mongrel.rb', line 8

def process(request, response)
  # only serve GET
  return original_process(request, response) if request.params['REQUEST_METHOD'] != 'GET'
  url = 'http://' + request.params["HTTP_HOST"] + request.params["REQUEST_URI"]
  snapshot = QuickServe::Rails::Snapshot.fetch(url)
  if snapshot
    response.start do |head,out|
      puts "quick_serve: served snapshot of #{url}"
      head["Content-Type"] = "text/html"
      out << snapshot
    end
  else
    original_process(request, response)
  end
end