Created
September 25, 2015 17:34
-
-
Save yaychris/66d7a47f7d01c283080a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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