summaryrefslogtreecommitdiff
path: root/app/controllers/static_config_controller.rb
blob: c78e006c700b963428c72cc0162ac803ad44abe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
# This controller is responsible for returning some static config files, such as /provider.json
#
class StaticConfigController < ActionController::Base
  include ControllerExtension::JsonFile

  before_filter :set_minimum_client_version
  before_filter :set_filename
  before_filter :fetch_file

  PROVIDER_JSON = Rails.root.join('config', 'provider', 'provider.json')

  def provider
    send_file
  end

  protected

  # ensure that the header X-Minimum-Client-Version is sent
  # regardless if a 200 or 304 (not modified) or 404 response is sent.
  def set_minimum_client_version
    response.headers["X-Minimum-Client-Version"] =
      APP_CONFIG[:minimum_client_version].to_s
  end

  def set_filename
    @filename = PROVIDER_JSON
  end
end