Sha256: 9b1370a8daa72486ba373eb41e7d19c84247dc6b65944a8ab9a4f3321b898c61

Contents?: true

Size: 681 Bytes

Versions: 5

Compression:

Stored size: 681 Bytes

Contents

module Ahoy
  class BaseController < ApplicationController
    # skip all filters except for authlogic
    filters = _process_action_callbacks.map(&:filter) - [:load_authlogic]
    if respond_to?(:skip_action)
      skip_action *filters
      before_action :verify_request_size
    else
      skip_filter *filters
      before_filter :verify_request_size
    end

    protected

    def ahoy
      @ahoy ||= Ahoy::Tracker.new(controller: self, api: true)
    end

    def verify_request_size
      if request.content_length > Ahoy.max_content_length
        logger.info "[ahoy] Payload too large"
        render text: "Payload too large\n", status: 413
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ahoy_matey-1.4.2 app/controllers/ahoy/base_controller.rb
ahoy_matey-1.4.1 app/controllers/ahoy/base_controller.rb
ahoy_matey-1.4.0 app/controllers/ahoy/base_controller.rb
ahoy_matey-1.3.1 app/controllers/ahoy/base_controller.rb
ahoy_matey-1.3.0 app/controllers/ahoy/base_controller.rb