Module: Adva::Static::Server

Defined in:
lib/adva/static/server.rb,
lib/adva/static/server/watch.rb,
lib/adva/static/server/export.rb,
lib/adva/static/server/static.rb,
lib/adva/static/server/request.rb,
lib/adva/static/server/watch/handler.rb

Defined Under Namespace

Modules: Request Classes: Export, Static, Watch

Constant Summary collapse

PURGE_HEADER =
'rack-cache.purge'
STORE_HEADER =
'rack-static.store'

Class Method Summary collapse

Class Method Details

.start(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/adva/static/server.rb', line 16

def start(options = {})
  require 'config/environment.rb'

  Rails::Application.configure do
    ActionController::Base.allow_forgery_protection = false
  end

  app = ::Rack::Builder.new {
    use Adva::Static::Server::Watch
    use Adva::Static::Server::Export
    use Adva::Static::Server::Static, File.expand_path(options[:root])
    run Rails.application
  }.to_app

  server = ::Rack::Server.new(:environment => options[:environment], :Port => options[:port])
  server.instance_variable_set(:@app, app) # TODO remove this once we can use rack-1.3.0
  server.start
end