Class: Reins::Application
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/reins.rb', line 19 def call(env) # `echo debug > debug.txt`; if env['PATH_INFO'] == '/favicon.ico' return [404, {'content-type' => 'text/html'}, []] end begin rack_app = get_rack_app(env) rack_app.call(env) rescue return [500, {'content-type' => 'text/html'}, [File.read('public/500.html')]] end # klass, act = get_controller_and_action(env) # controller = klass.new(env) # text = controller.send(act) # r = controller.get_response # if r # [r.status, r.headers, [r.body].flatten] # else # controller.render(act) # r = controller.get_response # [r.status, r.headers, [r.body].flatten] # end # begin # text = controller.send(act) # rescue # return [500, {'content-type' => 'text/html'}, # ['Server Error']] # end # [200, {'content-type' => 'text/html'}, # [text]] end |
#get_rack_app(env) ⇒ Object
82 83 84 85 |
# File 'lib/reins/routing.rb', line 82 def get_rack_app(env) raise "No routes!" unless @route_obj @route_obj.check_url env["PATH_INFO"] end |
#route(&block) ⇒ Object
77 78 79 80 |
# File 'lib/reins/routing.rb', line 77 def route(&block) @route_obj ||= RouteObject.new @route_obj.instance_eval(&block) end |