ウェブサービスを作っています。

Rails Metal サンプル

params でパラメータ取れるようにしてます。


app/metal/some_metal.rb

# Allow the metal piece to run in isolation
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)

class SomeMetal
  class << self
    def call(env)
      @request = Rack::Request.new(env)

      case env['PATH_INFO']
      when %r!^/some_metal/some_action/?$!
        [200, {"Content-Type" => "text/html"}, [some_action]]
      else
        [404, {"Content-Type" => "text/html"}, ["Not Found"]]
      end
    end

    private
    def some_action
      # ... some_action's code ...
    end

    def params
      HashWithIndifferentAccess.new @request.params
    end
  end
end