Class: Jets::Shim::Maintenance
- Inherits:
-
Object
- Object
- Jets::Shim::Maintenance
- Extended by:
- Util::Truthy, Memoist
- Defined in:
- lib/jets/shim/maintenance.rb
Class Method Summary collapse
- .app ⇒ Object
- .body ⇒ Object
- .call(env) ⇒ Object
-
.content_type ⇒ Object
IE: application/json; charset=utf-8 IE: text/html.
- .enabled? ⇒ Boolean
- .maintenance_file ⇒ Object
Methods included from Util::Truthy
Class Method Details
.app ⇒ Object
7 8 9 |
# File 'lib/jets/shim/maintenance.rb', line 7 def app self end |
.body ⇒ Object
21 22 23 |
# File 'lib/jets/shim/maintenance.rb', line 21 def body IO.read(maintenance_file) end |
.call(env) ⇒ Object
11 12 13 |
# File 'lib/jets/shim/maintenance.rb', line 11 def call(env) [503, {"Content-Type" => content_type}, [body]] end |
.content_type ⇒ Object
IE: application/json; charset=utf-8 IE: text/html
17 18 19 |
# File 'lib/jets/shim/maintenance.rb', line 17 def content_type maintenance_file.end_with?("json") ? "application/json" : "text/html" end |
.enabled? ⇒ Boolean
32 33 34 |
# File 'lib/jets/shim/maintenance.rb', line 32 def enabled? truthy?(ENV["JETS_MAINTENANCE"]) end |
.maintenance_file ⇒ Object
25 26 27 28 29 |
# File 'lib/jets/shim/maintenance.rb', line 25 def maintenance_file default_path = "#{__dir__}/maintenance/maintenance.html" paths = %w[public/maintenance.html public/maintenance.json] paths.find { |path| File.exist?(path) } || default_path end |