class Sapp::Base

Order of routing operations.

  1. Create Request.

  2. Parse request path.

  3. If path found unwrap handler in context of params and status.

  4. If path not found return a 404.

Public Class Methods

call(env) click to toggle source

Single Application

# File lib/sapp/base.rb, line 24
def self.call env
  req = Rack::Request.new env
  req_path = create_path req.path, req.request_method, routes

  if req_path.path?
    find_path req_path, req
  else
     not_found! req_path.verb, req_path.original
  end

end
create_path(path, method, routes) click to toggle source
# File lib/sapp/base.rb, line 53
def self.create_path path, method, routes
  req_path = Sapp::Path::Request.new path, method, routes
  req_path.parse
  req_path
end
find_path(req_path, req) click to toggle source
# File lib/sapp/base.rb, line 45
def self.find_path req_path, req
  handler   = Sapp::Handler.new req_path.handler, req, req_path.keys
  unwrapped = handler.unwrap
  response  = Sapp::Response.new handler.status, unwrapped

  response.process_handler
end
run(req) click to toggle source

Multiple applications to be used with router

# File lib/sapp/base.rb, line 37
def self.run req
  req_path = create_path req.path, req.request_method, routes

  if req_path.path?
    find_path req_path, req
  end
end