class RouteAction
  include EventMachine::Deferrable

  class << self
    def controller(name, app)
      controllers[name] ||= Object.const_get(name).new(app)
    end

    def controllers
      @controllers ||= {}
    end
  end

  def initialize(app, action:, callback:)
    @app, @action, @callback = app, action, callback
  end

  def run(request, response)
    if @action.is_a? Proc
      Cannon.logger.debug 'Action: Inline'
      @action.call(request, response)
    elsif @action.include? '#'
      controller, action = @action.split('#')
      RouteAction.controller(controller, @app).send(action, request, response)
    else
      Cannon.logger.debug "Action: #{@action}"
      @app.app_binding.send(@action, request, response)
    end

    if response.flushed?
      fail
    else
      setup_callback
      succeed(request, response)
    end
  end

private

  def setup_callback
    set_deferred_status nil
    callback do |request, response|
      @callback.run(request, response) unless @callback.nil?
    end
  end
end

class RouteAction
  include EventMachine::Deferrable

  class << self
    def controller(name, app)
      controllers[name] ||= Object.const_get(name).new(app)
    end

    def controllers
      @controllers ||= {}
    end
  end

  def initialize(app, action:, callback:)
    @app, @action, @callback = app, action, callback
  end

  def run(request, response)
    if @action.is_a? Proc
      Cannon.logger.debug 'Action: Inline'
      @action.call(request, response)
    elsif @action.include? '#'
      controller, action = @action.split('#')
      Cannon.logger.debug "Controller: #{controller}, Action: #{action}"
      RouteAction.controller(controller, @app).send(action, request, response)
    else
      Cannon.logger.debug "Action: #{@action}"
      @app.app_binding.send(@action, request, response)
    end

    if response.flushed?
      fail
    else
      setup_callback
      succeed(request, response)
    end
  end

private

  def setup_callback
    set_deferred_status nil
    callback do |request, response|
      @callback.run(request, response) unless @callback.nil?
    end
  end
end

Add logger debug line for controller based action requests
Add logger debug line for controller based action requests
