summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-12-30 13:32:11 -0800
committerjessib <jessib@riseup.net>2013-12-30 13:32:11 -0800
commit8db811678404aa9a33c54805f8fba4afb932c1f4 (patch)
treee94f2d44be2af63999fb1b332f8a795bb8a35b26 /app
parent7f12c795207ac818bffac42aa581bf1165f9e424 (diff)
parent62f31ab0358bc165c9a83806db1828365cb96572 (diff)
Merge branch 'develop' into feature/messages_api
Diffstat (limited to 'app')
-rw-r--r--app/controllers/static_config_controller.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/static_config_controller.rb b/app/controllers/static_config_controller.rb
new file mode 100644
index 0000000..c669316
--- /dev/null
+++ b/app/controllers/static_config_controller.rb
@@ -0,0 +1,24 @@
+#
+# This controller is responsible for returning some static config files, such as /provider.json
+#
+class StaticConfigController < ActionController::Base
+
+ PROVIDER_JSON = File.join(Rails.root, 'config', 'provider', 'provider.json')
+
+ #
+ # return the provider.json, ensuring that the header X-Minimum-Client-Version is sent
+ # regardless if a 200 or 304 (not modified) response is sent.
+ #
+ def provider
+ response.headers["X-Minimum-Client-Version"] = APP_CONFIG[:minimum_client_version].to_s
+ if File.exists?(PROVIDER_JSON)
+ if stale?(:last_modified => File.mtime(PROVIDER_JSON))
+ response.content_type = 'application/json'
+ render :text => File.read(PROVIDER_JSON)
+ end
+ else
+ render :text => 'not found', :status => 404
+ end
+ end
+
+end \ No newline at end of file