Class: Volt::DefaultMiddlewareStack
- Defined in:
- lib/volt/server/middleware/default_middleware_stack.rb
Class Method Summary collapse
-
.postboot_setup(volt_app, rack_app) ⇒ Object
Setup the middleware that we need to wait for components to boot before we can set them up.
-
.preboot_setup(volt_app, rack_app) ⇒ Object
Setup on the middleware we can setup before booting components.
Class Method Details
.postboot_setup(volt_app, rack_app) ⇒ Object
Setup the middleware that we need to wait for components to boot before we can set them up.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/volt/server/middleware/default_middleware_stack.rb', line 44 def self.postboot_setup(volt_app, rack_app) # Serve the opal files opal_files = OpalFiles.new(rack_app, volt_app.app_url, volt_app.app_path, volt_app.component_paths) volt_app.opal_files = opal_files volt_app.sprockets = opal_files.environment Volt::SprocketsHelpersSetup.new(volt_app) # Serve the main html files from public, also figure out # which JS/CSS files to serve. rack_app.use IndexFiles, volt_app, volt_app.component_paths, opal_files rack_app.use HttpResource, volt_app, volt_app.router # serve assets from public rack_app.use Rack::Static, urls: [''], root: 'public', index: 'index.html', header_rules: [ [:all, { 'Cache-Control' => 'public, max-age=86400' }] ] rack_app.run lambda { |env| [404, { 'Content-Type' => 'text/html; charset=utf-8' }, ['404 - page not found']] } end |
.preboot_setup(volt_app, rack_app) ⇒ Object
Setup on the middleware we can setup before booting components
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/volt/server/middleware/default_middleware_stack.rb', line 16 def self.preboot_setup(volt_app, rack_app) # Should only be used in production if Volt.config.deflate rack_app.use Rack::Deflater rack_app.use Rack::Chunked end rack_app.use Rack::ContentLength rack_app.use Rack::KeepAlive rack_app.use Rack::ConditionalGet rack_app.use Rack::ETag rack_app.use Rack::Session::Cookie, { key: 'rack.session', # domain: 'localhost.com', path: '/', expire_after: 2592000, secret: Volt.config.app_secret } rack_app.use QuietCommonLogger if Volt.env.development? || Volt.env.test? rack_app.use Rack::ShowExceptions end end |