module Unpoly::Rails::RequestEchoHeaders
Installs a `before_action` 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.
Public Class Methods
included(base)
click to toggle source
# File lib/unpoly/rails/request_echo_headers.rb, line 12 def self.included(base) if base.respond_to?(:before_action) base.before_action :set_up_request_echo_headers else base.before_filter :set_up_request_echo_headers end end
Private Instance Methods
set_up_request_echo_headers()
click to toggle source
# File lib/unpoly/rails/request_echo_headers.rb, line 22 def set_up_request_echo_headers response.headers['X-Up-Location'] = up.request_url_without_up_params response.headers['X-Up-Method'] = request.method end