# frozen_string_literal: true

require_relative "config/cpanel_bootstrap"
require_relative "config/environment"

class Rack3SetCookieHeader
  def initialize(app)
    @app = app
  end

  def call(env)
    status, headers, body = @app.call(env)
    flat = {}
    headers.each do |key, value|
      flat[key] = value.is_a?(Array) ? value.join("\n") : value
    end
    [status, flat, body]
  end
end

run Rack3SetCookieHeader.new(Rails.application)
