Class: Everywhere::MobileConfigsController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- Everywhere::MobileConfigsController
- Defined in:
- lib/everywhere/mobile_configs_controller.rb
Overview
Serves the mobile shells' remote path configuration in Rails apps:
GET /everywhere/ios_v1.json -> MobileConfigsController#show
The route is appended by Everywhere::Engine, so it shows up in
rails routes and the app can override it by drawing its own. Inherits
ActionController::API on purpose:
* never the app's ApplicationController — its before_actions
(authentication!) would lock the shells out, and
* not ActionController::Base — its `helper :all` resolution reaches
into the host app's helpers, which aren't loadable when the gem is
required during boot. A JSON endpoint needs none of that.
everywhere.yml is re-read on every request: tab changes go live with a deploy — or a plain file save in development, where responses are explicitly uncached so the dev shell's reload polling sees them instantly.
Instance Method Summary collapse
-
#reset ⇒ Object
GET /everywhere/reset?to=/path — the native "reset the app" page.
- #show ⇒ Object
Instance Method Details
#reset ⇒ Object
GET /everywhere/reset?to=/path — the native "reset the app" page. Auth
flows redirect the shell here so it rebuilds cleanly before landing on
to. Never cached (it must run every time).
40 41 42 43 44 |
# File 'lib/everywhere/mobile_configs_controller.rb', line 40 def reset response.headers["cache-control"] = "no-store" render html: Everywhere.mobile_reset_html(params[:to]).html_safe, layout: false, content_type: "text/html" end |
#show ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/everywhere/mobile_configs_controller.rb', line 23 def show config = Config.load(::Rails.root.to_s) # Never cache: the response depends on the session (filter_tabs can hide # tabs when signed out), so a shared/public cache could serve one user's # tabs to another, and a client cache would serve stale tabs across # sign-in/out. The endpoint is a couple of milliseconds — no cache needed. response.headers["cache-control"] = "no-store" os = params[:platform_v1].delete_suffix("_v1") tabs = Everywhere.resolve_tabs(config.tabs_for(os), request) render json: config.path_configuration_hash(os, tabs: tabs) end |