Permalink
Browse files

env is accessable directly, no need to use request.env

Conflicts:

	README.ru.rdoc
  • Loading branch information...
1 parent d2d0ac3 commit a6659f4d5c1664f4b2eaf467df97abb8ca0b7b7d @rkh rkh committed Apr 17, 2011
Showing with 20 additions and 20 deletions.
  1. +2 −2 README.de.rdoc
  2. +2 −2 README.es.rdoc
  3. +2 −2 README.fr.rdoc
  4. +1 −1 README.hu.rdoc
  5. +1 −1 README.jp.rdoc
  6. +1 −1 README.pt-br.rdoc
  7. +1 −1 README.pt-pt.rdoc
  8. +2 −2 README.rdoc
  9. +2 −2 README.zh.rdoc
  10. +2 −2 lib/sinatra/base.rb
  11. +4 −4 test/routing_test.rb
View
@@ -903,7 +903,7 @@ Manchmal entspricht +pass+ nicht den Anforderungen, wenn das Ergebnis einer
anderen Route gefordert wird. Um das zu erreichen, lässt sich +call+ nutzen:
get '/foo' do
- status, headers, body = call request.env.merge("PATH_INFO" => '/bar')
+ status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
end
@@ -1357,7 +1357,7 @@ Routen-Block oder in einem Filter geworfen wurde. Die Exception kann über die
Benutzerdefinierte Fehler:
error MeinFehler do
- 'Au weia, ' + request.env['sinatra.error'].message
+ 'Au weia, ' + env['sinatra.error'].message
end
Dann, wenn das passiert:
View
@@ -874,7 +874,7 @@ Cuando querés obtener el resultado de la llamada a una ruta, +pass+ no te va a
servir. Para lograr esto, podés usar +call+:
get '/foo' do
- status, headers, body = call request.env.merge("PATH_INFO" => '/bar')
+ status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
end
@@ -1365,7 +1365,7 @@ obtener de la variable Rack <tt>sinatra.error</tt>:
Errores personalizados:
error MiErrorPersonalizado do
- 'Lo que pasó fue...' request.env['sinatra.error'].message
+ 'Lo que pasó fue...' + env['sinatra.error'].message
end
Entonces, si pasa esto:
View
@@ -894,7 +894,7 @@ souhaitez obtenir le résultat d'une autre route. Pour cela, utilisez
simplement +call+ :
get '/foo' do
- status, headers, body = call request.env.merge("PATH_INFO" => '/bar')
+ status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
end
@@ -1399,7 +1399,7 @@ variable Rack <tt>sinatra.error</tt>:
Erreur sur mesure:
error MonErreurSurMesure do
- 'Donc il est arrivé ceci...' + request.env['sinatra.error'].message
+ 'Donc il est arrivé ceci...' + env['sinatra.error'].message
end
Donc si ceci arrive:
View
@@ -399,7 +399,7 @@ előszűrő kivételt vált ki. A kivétel objektum lehívható a
Egyéni hibakezelés:
error MyCustomError do
- 'Szóval az van, hogy...' + request.env['sinatra.error'].message
+ 'Szóval az van, hogy...' + env['sinatra.error'].message
end
És amikor fellép:
View
@@ -700,7 +700,7 @@ body部を指定することもできます ...
エラーをカスタマイズする場合は、
error MyCustomError do
- 'エラーメッセージ...' + request.env['sinatra.error'].message
+ 'エラーメッセージ...' + env['sinatra.error'].message
end
と書いておいて,下記のように呼び出します。
View
@@ -431,7 +431,7 @@ Rack <tt>sinatra.error</tt>:
Erros customizados:
error MeuErroCustomizado do
- 'Então que aconteceu foi...' + request.env['sinatra.error'].message
+ 'Então que aconteceu foi...' + env['sinatra.error'].message
end
Então, se isso acontecer:
View
@@ -430,7 +430,7 @@ Rack <tt>sinatra.error</tt>:
Erros personalizados:
error MeuErroPersonalizado do
- 'O que aconteceu foi...' + request.env['sinatra.error'].message
+ 'O que aconteceu foi...' + env['sinatra.error'].message
end
Então, se isso acontecer:
View
@@ -854,7 +854,7 @@ Sometimes +pass+ is not what you want, instead you would like to get the result
of calling another route. Simply use +call+ to achieve this:
get '/foo' do
- status, headers, body = call request.env.merge("PATH_INFO" => '/bar')
+ status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
end
@@ -1325,7 +1325,7 @@ block or a filter. The exception object can be obtained from the
Custom errors:
error MyCustomError do
- 'So what happened was...' + request.env['sinatra.error'].message
+ 'So what happened was...' + env['sinatra.error'].message
end
Then, if this happens:
View
@@ -843,7 +843,7 @@ Session被用来在请求之间保持状态。如果被激活,每一个用户
。简单的使用 +call+ 可以做到这一点:
get '/foo' do
- status, headers, body = call request.env.merge("PATH_INFO" => '/bar')
+ status, headers, body = call env.merge("PATH_INFO" => '/bar')
[status, body.upcase]
end
@@ -1314,7 +1314,7 @@ Sinatra会自动处理range请求。
自定义错误:
error MyCustomError do
- 'So what happened was...' + request.env['sinatra.error'].message
+ 'So what happened was...' + env['sinatra.error'].message
end
那么,当这个发生的时候:
View
@@ -367,7 +367,7 @@ def last_modified(time)
time = time_for time
response['Last-Modified'] = time.httpdate
# compare based on seconds since epoch
- halt 304 if Time.httpdate(request.env['HTTP_IF_MODIFIED_SINCE']).to_i >= time.to_i
+ halt 304 if Time.httpdate(env['HTTP_IF_MODIFIED_SINCE']).to_i >= time.to_i
rescue ArgumentError
end
@@ -696,7 +696,7 @@ def pass(&block)
# Forward the request to the downstream app -- middleware only.
def forward
fail "downstream app not set" unless @app.respond_to? :call
- status, headers, body = @app.call(@request.env)
+ status, headers, body = @app.call env
@response.status = status
@response.body = body
@response.headers.merge! headers
@@ -686,10 +686,10 @@ class RoutingTest < Test::Unit::TestCase
it "filters by accept header" do
mock_app {
get '/', :provides => :xml do
- request.env['HTTP_ACCEPT']
+ env['HTTP_ACCEPT']
end
get '/foo', :provides => :html do
- request.env['HTTP_ACCEPT']
+ env['HTTP_ACCEPT']
end
}
@@ -714,7 +714,7 @@ class RoutingTest < Test::Unit::TestCase
mock_app {
get '/', :provides => types do
- request.env['HTTP_ACCEPT']
+ env['HTTP_ACCEPT']
end
}
@@ -729,7 +729,7 @@ class RoutingTest < Test::Unit::TestCase
it 'degrades gracefully when optional accept header is not provided' do
mock_app {
get '/', :provides => :xml do
- request.env['HTTP_ACCEPT']
+ env['HTTP_ACCEPT']
end
get '/' do
'default'

0 comments on commit a6659f4

Please sign in to comment.