Class: ESI::Dispatcher
- Inherits:
-
Mongrel::HttpHandler
- Object
- Mongrel::HttpHandler
- ESI::Dispatcher
- Includes:
- Log
- Defined in:
- lib/esi/dispatcher.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(options) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #process(request, response) ⇒ Object
Methods included from Log
#log, #log_debug, #log_error, #log_request, #msg
Constructor Details
#initialize(options) ⇒ Dispatcher
Returns a new instance of Dispatcher.
13 14 15 16 |
# File 'lib/esi/dispatcher.rb', line 13 def initialize( ) super() @config = ESI::Config.new( ) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/esi/dispatcher.rb', line 8 def config @config end |
Instance Method Details
#process(request, response) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/esi/dispatcher.rb', line 18 def process(request, response) start = Time.now url = @config.router.url_for(request.params["REQUEST_URI"]) chunk_count, bytes_sent, status, sent_from_cache = ESI::Proxy.new(@config).process(url, request,response) rescue => e log_error "\n#{e.}: error at #{e.backtrace.first} msg at #{__FILE__}:#{__LINE__}\n" ensure log_request "\n#{url}, #{Time.now - start} seconds with status #{status} #{sent_from_cache ? "from cache" : ''} and #{chunk_count} chunks, #{bytes_sent} bytes\n" end |