Sha256: 2effffb4ddde4a45a41a67645173f8c07abbef49ec799d507d19a9b1177ba61f
Contents?: true
Size: 934 Bytes
Versions: 4
Compression:
Stored size: 934 Bytes
Contents
module Remotipart # A middleware to look for our form parameters and # encourage Rails to respond with the requested format class Middleware def initialize app @app = app end def call env # Get request params begin params = Rack::Request.new(env).params rescue TypeError => e ::Rails.logger.warn e.message ::Rails.logger.warn e.backtrace.join("\n") end if params # This was using an iframe transport, and is therefore an XHR # This is required if we're going to override the http_accept if params['X-Requested-With'] == 'IFrame' env['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest' end # Override the accepted format, because it isn't what we really want if params['X-HTTP-Accept'] env['HTTP_ACCEPT'] = params['X-HTTP-Accept'] end end @app.call(env) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
remotipart-1.4.4 | lib/remotipart/middleware.rb |
remotipart-1.4.3 | lib/remotipart/middleware.rb |
remotipart-1.4.2 | lib/remotipart/middleware.rb |
remotipart-1.4.0 | lib/remotipart/middleware.rb |