This project is archived and is in readonly mode.

Changeset [61a41154f7d50099da371e0d2f22fd25ab9113c2] by Joshua Peek

December 17th, 2008 @ 03:53 PM

Make generated Metal bits a pure rack endpoint application (not middleware)

Instead of calling super to pass the request on, return a 404. The modified app looks like this:

# app/metal/poller.rb class Poller

def self.call(env)
  if env["PATH_INFO"] =~ /^\/poller/
    [200, {"Content-Type" => "text/html"}, "Hello, World!"]
  else
    [404, {"Content-Type" => "text/html"}, "Not Found"]
  end
end

end

But you aren't locked in to just Rails:

# app/metal/api.rb require 'sinatra' Sinatra::Application.default_options.merge!(:run => false, :env => :production) Api = Sinatra.application unless defined? Api

get '/interesting/new/ideas' do

'Hello Sinatra!'

end http://github.com/rails/rails/co...

Committed by Joshua Peek

  • M railties/lib/initializer.rb
  • M railties/lib/rails/rack/metal.rb
  • M railties/lib/rails_generator/generators/components/metal/templates/metal.rb

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>