Class: Sapp::Base
- Inherits:
-
Object
- Object
- Sapp::Base
- Defined in:
- lib/sapp/base.rb
Overview
Order of routing operations.
-
Create Request.
-
Parse request path.
-
If path found unwrap handler in context of params and status.
-
If path not found return a 404.
Class Method Summary collapse
-
.call(env) ⇒ Object
Single Application.
- .create_path(path, method, routes) ⇒ Object
- .find_path(req_path, req) ⇒ Object
-
.run(req) ⇒ Object
Multiple applications to be used with router.
Methods included from Routes
add, delete, get, head, namespace, not_found!, patch, post, put, root, route_map, routes
Methods included from Resources
create, destroy, index, resources, show, update
Class Method Details
.call(env) ⇒ Object
Single Application
24 25 26 27 28 29 30 31 32 33 34 |
# 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) ⇒ Object
53 54 55 56 57 |
# 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) ⇒ Object
45 46 47 48 49 50 51 |
# 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) ⇒ Object
Multiple applications to be used with router
37 38 39 40 41 42 43 |
# 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 |