lib/cuba.rb in cuba-3.0.0 vs lib/cuba.rb in cuba-3.0.1.rc1
- old
+ new
@@ -5,11 +5,11 @@
class Response
attr_accessor :status
attr :headers
- def initialize(status = 200, headers = { "Content-Type" => "text/html" })
+ def initialize(status = 200, headers = { "Content-Type" => "text/html; charset=utf-8" })
@status = status
@headers = headers
@body = []
@length = 0
end
@@ -86,13 +86,10 @@
def self.inherited(child)
child.settings.replace(settings)
end
- attr :env
- attr :req
- attr :res
attr :captures
def initialize(&blk)
@blk = blk
@captures = []
@@ -104,13 +101,25 @@
def call(env)
dup.call!(env)
end
+ def req
+ Thread.current[:_cuba_req]
+ end
+
+ def res
+ Thread.current[:_cuba_res]
+ end
+
+ def env
+ Thread.current[:_cuba_env]
+ end
+
def call!(env)
- @env = env
- @req = Rack::Request.new(env)
- @res = Cuba::Response.new
+ Thread.current[:_cuba_env] = env
+ Thread.current[:_cuba_req] = Rack::Request.new(env)
+ Thread.current[:_cuba_res] = Cuba::Response.new
# This `catch` statement will either receive a
# rack response tuple via a `halt`, or will
# fall back to issuing a 404.
#