Sha256: b09c9ad24133a3e0f6009f4779308ec8256b77b7e7366925f9203657ebf7615e

Contents?: true

Size: 679 Bytes

Versions: 7

Compression:

Stored size: 679 Bytes

Contents

module Rodauth
  module Rails
    class App
      # Roda plugin that extends middleware plugin by propagating response headers.
      module Middleware
        def self.load_dependencies(app)
          app.plugin :hooks
        end

        def self.configure(app)
          app.after do
            if response.empty? && response.headers.any?
              env["rodauth.rails.headers"] = response.headers
            end
          end

          app.plugin :middleware, handle_result: -> (env, res) do
            if headers = env.delete("rodauth.rails.headers")
              res[1] = headers.merge(res[1])
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rodauth-rails-0.9.1 lib/rodauth/rails/app/middleware.rb
rodauth-rails-0.9.0 lib/rodauth/rails/app/middleware.rb
rodauth-rails-0.8.2 lib/rodauth/rails/app/middleware.rb
rodauth-rails-0.8.1 lib/rodauth/rails/app/middleware.rb
rodauth-rails-0.8.0 lib/rodauth/rails/app/middleware.rb
rodauth-rails-0.7.0 lib/rodauth/rails/app/middleware.rb
rodauth-rails-0.6.1 lib/rodauth/rails/app/middleware.rb