Sha256: be62a2f8c3be5d44ed752467c13fcec4b1742aa6267e4a545f67597700c1c837

Contents?: true

Size: 724 Bytes

Versions: 32

Compression:

Stored size: 724 Bytes

Contents

module Unpoly
  module Rails
    ##
    # Installs a `before_filter` into all controllers which echoes the
    # request's URL as a response header `X-Up-Location` and the request's
    # HTTP method as `X-Up-Method`.
    #
    # The Unpoly frontend requires these headers to detect redirects,
    # which are otherwise undetectable for an AJAX client.
    module RequestEchoHeaders

      def self.included(base)
        base.before_filter :set_up_request_echo_headers
      end

      private
      
      def set_up_request_echo_headers
        headers['X-Up-Location'] = request.original_url
        headers['X-Up-Method'] = request.method
      end

      ActionController::Base.send(:include, self)

    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
unpoly-rails-0.35.1 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.35.0 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.34.2 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.34.1 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.34.0 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.33.0 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.32.0 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.31.2 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.31.1 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.31.0 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.30.1 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.30.0 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.29.0 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.28.1 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.28.0 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.27.3 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.27.2 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.27.1 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.27.0 lib/unpoly/rails/request_echo_headers.rb
unpoly-rails-0.26.2 lib/unpoly/rails/request_echo_headers.rb