Class: RailsAppVersion::AppInfoMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_app_version/app_info_middleware.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  version_header: "X-App-Version",
  environment_header: "X-App-Environment",
  revision_header: "X-App-Revision",
  include_revision: false
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ AppInfoMiddleware

Returns a new instance of AppInfoMiddleware.



12
13
14
15
# File 'lib/rails_app_version/app_info_middleware.rb', line 12

def initialize(app, options = {})
  @app = app
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rails_app_version/app_info_middleware.rb', line 17

def call(env)
  status, headers, response = @app.call(env)

  headers[@options[:version_header]] = Rails.application.version.full
  headers[@options[:environment_header]] = Rails.application.env

  [ status, headers, response ]
end