Module: Serve::Rails::ServeController

Defined in:
lib/serve/rails/serve_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/serve/rails/serve_controller.rb', line 5

def show
  response.headers.delete('Cache-Control')
  cache = Serve::Rails.cache(request)
  if cache.response_cached?(request.path)
    cache.update_response(request.path, response, request)
  else
    mount = Serve::Rails.configuration.mounts.detect {|m| m.route == params[:serve_route]}
    if path = mount.resolve_path(params[:path] || '/')
      handler_class = Serve::FileTypeHandler.find(path)
      handler = handler_class.new(mount.root_path, path)
      install_view_helpers(handler, mount.view_helpers) if handler_class == Serve::DynamicHandler
      handler.process(request, response)
      cache.cache_response(request.path, response)
    else
      render_not_found
    end
  end
  @performed_render = true
end