Module: StackMob::CLI::LocalServer

Included in:
Main
Defined in:
lib/stackmob/cli/local_server.rb

Defined Under Namespace

Classes: Server

Constant Summary collapse

DEFAULT_PORT =
4567

Instance Method Summary collapse

Instance Method Details

#start_local_server(port = DEFAULT_PORT, path_root = '.') ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/stackmob/cli/local_server.rb', line 43

def start_local_server(port = DEFAULT_PORT, path_root = '.')
  app = ::Rack::Builder.new do 
    use StackMob::Middleware::Proxy
    use StackMob::Middleware::Rewrite

    endpoint = ::Rack::Static.new lambda { |e| [] }, :urls => ['/'], :root => path_root
    map "/" do 
      run endpoint
    end
  end.to_app        
  Server.start :app => app, :host => '0.0.0.0', :server => 'thin', :Port => port
end