Skip to content

Instantly share code, notes, and snippets.

@yaychris
Created September 25, 2015 17:34
Show Gist options
  • Select an option

  • Save yaychris/66d7a47f7d01c283080a to your computer and use it in GitHub Desktop.

Select an option

Save yaychris/66d7a47f7d01c283080a to your computer and use it in GitHub Desktop.
require 'rack'
require 'action_dispatch'
class Controller
def self.action(name)
-> (env) do
new(env).send(name)
end
end
attr_reader :env, :request
def initialize(env)
@env = env
@request = Rack::Request.new(env)
end
end
class AnimalsController < Controller
def index
[200, {}, ['aminals']]
end
end
class HomeController < Controller
def index
[200, {}, ['yay']]
end
end
routes = ActionDispatch::Routing::RouteSet.new
routes.draw do
get '/animals', to: 'animals#index'
get '/', to: 'home#index'
end
run routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment