class Algernon::Application
Attributes
path[R]
request[R]
router[R]
routes[R]
verb[R]
Public Class Methods
new()
click to toggle source
# File lib/algernon/application.rb, line 11 def initialize @router = Routing::Router.new end
Public Instance Methods
call(env)
click to toggle source
# File lib/algernon/application.rb, line 15 def call(env) env = MethodOverride.apply_to(env) @request = Rack::Request.new(env) if router.has_routes? respond_to_request else default_response end end
Private Instance Methods
default_response()
click to toggle source
# File lib/algernon/application.rb, line 35 def default_response Rack::Response.new( "<center><b>Algernon::Penny wise, Pound foolish</center>", 200, "Content-Type" => "text/html" ) end
page_not_found()
click to toggle source
# File lib/algernon/application.rb, line 43 def page_not_found Rack::Response.new( "<center><h1>404 Error</h1>Page not found</center>", 404, "Content-Type" => "text/html" ) end
respond_to_request()
click to toggle source
# File lib/algernon/application.rb, line 25 def respond_to_request route = router.get_match(request.request_method, request.path_info) if route handler = Dispatcher.new(request, route) handler.response else page_not_found end end