Skip to content

Commit

Permalink
Add session support, which is off by default. Enable by calling set_o…
Browse files Browse the repository at this point in the history
…ption(:sessions => true).

The TODO-List-Example now works again.
  • Loading branch information
Markus Prinz committed Apr 7, 2008
1 parent 15d360e commit 4ce6231
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/sinatra.rb
Expand Up @@ -114,7 +114,13 @@ def env
end

def build_application
Rack::CommonLogger.new(application)
app = if Sinatra.options[:session] == true
Rack::Session::Cookie.new(application)
else
application
end

Rack::CommonLogger.new(app)
end

def run
Expand Down Expand Up @@ -587,7 +593,7 @@ def initialize(request, response, route_params)
end

def params
@params = @route_params.merge(@request.params)
@params = @route_params.merge(@request.params).symbolize_keys
end

def stop(*args)
Expand All @@ -598,6 +604,10 @@ def complete(returned)
@response.body || returned
end

def session
@request.env['rack.session']
end

private

def method_missing(name, *args, &b)
Expand All @@ -620,7 +630,8 @@ def self.default_options
:env => :development,
:root => Dir.pwd,
:views => Dir.pwd + '/views',
:public => Dir.pwd + '/public'
:public => Dir.pwd + '/public',
:sessions => false,
}
end

Expand Down

0 comments on commit 4ce6231

Please sign in to comment.