Class: Chaplin::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/chaplin/server.rb

Class Method Summary collapse

Class Method Details

.add_route(endpoint, response) ⇒ Object



19
20
21
22
23
24
# File 'lib/chaplin/server.rb', line 19

def self.add_route(endpoint, response)
  send(endpoint.http_method, endpoint.path) do
    params_with_cookies_and_session = (params || {}).merge(cookies: cookies, session: session)
    response.execute(params_with_cookies_and_session, self)
  end
end

.setup(project_path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/chaplin/server.rb', line 8

def self.setup(project_path)
  set :public_folder, project_path + '/public'
  set :static_cache_control, [:public, :max_age => 300]

  set :show_exceptions, false

  error do
    env['sinatra.error'].message + "\n" + env['sinatra.error'].backtrace.join("\n")
  end
end