Class: Tres::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/tres/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Server

Returns a new instance of Server.



8
9
10
11
# File 'lib/tres/server.rb', line 8

def initialize app
  @app = app
  @static_server = Rack::File.new @app.root/'build'
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



6
7
8
# File 'lib/tres/server.rb', line 6

def app
  @app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
# File 'lib/tres/server.rb', line 13

def call env
  response = serve_static env
  response = serve_asset env if not_found?(response)
  response = serve_index if not_found?(response)
  response
end

#to_rack_appObject



20
21
22
23
24
25
26
27
# File 'lib/tres/server.rb', line 20

def to_rack_app
  me = self
  Rack::Builder.new do
    use ::Tres::RackLogger
    use Rack::Lint
    run me
  end      
end