aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/rails_on_rack.textile
diff options
context:
space:
mode:
authorCheah Chu Yeow <chuyeow@gmail.com>2010-04-19 18:29:18 +0800
committerCheah Chu Yeow <chuyeow@gmail.com>2010-04-19 18:29:18 +0800
commite00c72c9718e518eb99058781f6ee71fa46b38fe (patch)
tree3b99c4925a9dbf48a95e8e850d93e6a39d209f93 /railties/guides/source/rails_on_rack.textile
parenta870c4928cac8bf14ddbda487108bce45bed0fa2 (diff)
downloadrails-e00c72c9718e518eb99058781f6ee71fa46b38fe.tar.gz
rails-e00c72c9718e518eb99058781f6ee71fa46b38fe.tar.bz2
rails-e00c72c9718e518eb99058781f6ee71fa46b38fe.zip
Rails on Rack Rails guide: indicate that Metal pieces now require an "X-Cascade" header with a value of "pass" to continue the Metal chain execution instead of a HTTP 404 response. Also removed reference to old code.
Diffstat (limited to 'railties/guides/source/rails_on_rack.textile')
-rw-r--r--railties/guides/source/rails_on_rack.textile22
1 files changed, 5 insertions, 17 deletions
diff --git a/railties/guides/source/rails_on_rack.textile b/railties/guides/source/rails_on_rack.textile
index d0d86e99f2..512be43668 100644
--- a/railties/guides/source/rails_on_rack.textile
+++ b/railties/guides/source/rails_on_rack.textile
@@ -247,7 +247,7 @@ class Poller
if env["PATH_INFO"] =~ /^\/poller/
[200, {"Content-Type" => "text/html"}, ["Hello, World!"]]
else
- [404, {"Content-Type" => "text/html"}, ["Not Found"]]
+ [404, {"Content-Type" => "text/html", "X-Cascade" => "pass"}, ["Not Found"]]
end
end
end
@@ -257,23 +257,13 @@ Metal applications within +app/metal+ folders in plugins will also be discovered
Metal applications are an optimization. You should make sure to "understand the related performance implications":http://weblog.rubyonrails.org/2008/12/20/performance-of-rails-metal before using it.
-h4. Execution Order
-
-All Metal Applications are executed by +Rails::Rack::Metal+ middleware, which is a part of the +ActionController::MiddlewareStack+ chain.
+WARNING: To continue the Metal chain execution, return an +X-Cascade+ HTTP header with a value of +pass+.
-Here's the primary method responsible for running the Metal applications:
+h4. Execution Order
-<ruby>
-def call(env)
- @metals.keys.each do |app|
- result = app.call(env)
- return result unless result[0].to_i == 404
- end
- @app.call(env)
-end
-</ruby>
+All Metal Applications are executed in alphabetical order of their filenames, so +aaa.rb+ will come before +bbb.rb+ in the metal chain.
-In the code above, +@metals+ is an ordered hash of metal applications. Due to the default alphabetical ordering, +aaa.rb+ will come before +bbb.rb+ in the metal chain.
+You can override the default ordering in your environment. Simply add a line like the following to +config/application.rb+
It is, however, possible to override the default ordering in your environment. Simply add a line like the following to +config/environment.rb+
@@ -283,8 +273,6 @@ config.metals = ["Bbb", "Aaa"]
Each string in the array should be the name of your metal class. If you do this then be warned that any metal applications not listed will not be loaded.
-WARNING: Metal applications cannot return the HTTP Status +404+ to a client, as it is used for continuing the Metal chain execution. Please use normal Rails controllers or a custom middleware if returning +404+ is a requirement.
-
h3. Resources
h4. Learning Rack