accept a hash as sessions setting
This commit is contained in:
parent
eb2871380c
commit
0c9e3d869e
2
CHANGES
2
CHANGES
|
@ -2,6 +2,8 @@
|
|||
|
||||
* Added support for HTTP PATCH requests. (Konstantin Haase)
|
||||
|
||||
* The sessions setting now may be an options hash. (Konstantin Haase)
|
||||
|
||||
* Important: 1.8.6 support has been dropped. (Konstantin Haase)
|
||||
|
||||
= 1.2.1 / 2011-03-17
|
||||
|
|
|
@ -810,6 +810,11 @@ set the secret yourself, so all your application instances share it:
|
|||
|
||||
set :session_secret, 'super secret'
|
||||
|
||||
If you want to configure it further, you may also store a hash with options in
|
||||
the +sessions+ setting:
|
||||
|
||||
set :sessions, :domain => 'foo.com'
|
||||
|
||||
=== Halting
|
||||
|
||||
To immediately stop a request within a filter or route use:
|
||||
|
|
|
@ -1248,7 +1248,9 @@ module Sinatra
|
|||
private
|
||||
def setup_sessions(builder)
|
||||
return unless sessions?
|
||||
builder.use Rack::Session::Cookie, :secret => session_secret
|
||||
options = { :secret => session_secret }
|
||||
options.merge! sessions.to_hash if sessions.respond_to? :to_hash
|
||||
builder.use Rack::Session::Cookie, options
|
||||
end
|
||||
|
||||
def detect_rack_handler
|
||||
|
|
|
@ -284,6 +284,19 @@ class HelpersTest < Test::Unit::TestCase
|
|||
get '/'
|
||||
assert_body 'ok'
|
||||
end
|
||||
|
||||
it 'accepts an options hash' do
|
||||
mock_app do
|
||||
set :sessions, :foo => :bar
|
||||
get '/' do
|
||||
assert_equal env['rack.session.options'][:foo], :bar
|
||||
'ok'
|
||||
end
|
||||
end
|
||||
|
||||
get '/'
|
||||
assert_body 'ok'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'mime_type' do
|
||||
|
|
Loading…
Reference in New Issue