Sha256: 00718c9ad2d4ed160f471a4ea34bc9a809a222d69eed30dec96e8aa098d99109

Contents?: true

Size: 538 Bytes

Versions: 1

Compression:

Stored size: 538 Bytes

Contents

module Rack
  class HerokuEnv
    VERSION = '0.1.1'

    def initialize(app)
      @app = app
    end

    def call(env)
      response = @app.call(env)

      heroku_vars(env).each do |variable_name|
        response[1][header_name_for(variable_name)] = env[variable_name]
      end

      response
    end

    private


    def heroku_vars(env)
      env.keys.grep(/\AHTTP_X_HEROKU/)
    end

    def header_name_for(variable_name)
      variable_name.gsub(/\AHTTP_/, '').split('_').map{|w| w.capitalize }.join('-')
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-heroku_env-0.1.1 lib/rack/heroku_env.rb