Skip to content

Instantly share code, notes, and snippets.

@svs
Created August 27, 2013 14:58
Show Gist options
  • Save svs/6354679 to your computer and use it in GitHub Desktop.
Save svs/6354679 to your computer and use it in GitHub Desktop.
class ChessApp
def self.routes
@routes ||= ActionDispatch::Routing::RouteSet.new.tap do |r|
r.draw do
resources :games, :only => [:index, :create, :show, :update]
end
end
end
def call(env)
env.update('POST_DATA' => Rack::Utils.parse_nested_query(env['rack.input'].read))
env['rack.input'].rewind
# above lines are to capture POST data in the env hash. No idea why Rack doesn't already do this.
Router.new(self.class.routes, env).call
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment