aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/rack/metal.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-12-16 13:11:51 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-16 13:15:06 -0600
commit8c3a54366435eebc2c8aa63b63e1349ce74a7b38 (patch)
tree547451f6c639994a948f8cba6505022458aedeac /railties/lib/rails/rack/metal.rb
parentc4023cbe206415cf3ca1ca92cd9980a4aa4aed00 (diff)
downloadrails-8c3a54366435eebc2c8aa63b63e1349ce74a7b38.tar.gz
rails-8c3a54366435eebc2c8aa63b63e1349ce74a7b38.tar.bz2
rails-8c3a54366435eebc2c8aa63b63e1349ce74a7b38.zip
Introduce Rails Metal
# app/metal/poller.rb class Poller < Rails::Rack::Metal def call(env) if env["PATH_INFO"] =~ /^\/poller/ [200, {"Content-Type" => "application/json"}, Message.recent.to_json] else super end end end * There is a generator to help you get started `script/generate metal poller` * Also, metal bits can be ran standalone with rackup `rackup app/metal/poller.rb`
Diffstat (limited to 'railties/lib/rails/rack/metal.rb')
-rw-r--r--railties/lib/rails/rack/metal.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/railties/lib/rails/rack/metal.rb b/railties/lib/rails/rack/metal.rb
new file mode 100644
index 0000000000..8dfbedad90
--- /dev/null
+++ b/railties/lib/rails/rack/metal.rb
@@ -0,0 +1,21 @@
+module Rails
+ module Rack
+ class Metal
+ NotFound = lambda { |env|
+ [404, {"Content-Type" => "text/html"}, "Not Found"]
+ }
+
+ def self.call(env)
+ new(NotFound).call(env)
+ end
+
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ @app.call(env)
+ end
+ end
+ end
+end