Class: Lifer::Dev::Router
- Inherits:
-
Object
- Object
- Lifer::Dev::Router
- Defined in:
- lib/lifer/dev/router.rb
Overview
The dev router is responsible for routing requests from the ‘Lifer::Dev:Server`. Note that in production, the dev server would never be used. So the dev router does not need to be very sophisticated.
Instance Attribute Summary collapse
-
#build_directory ⇒ Object
Returns the value of attribute build_directory.
Instance Method Summary collapse
-
#initialize(build_directory:) ⇒ void
constructor
Builds an instance of the router.
-
#response_for(request_env) ⇒ Lifer::Dev::Response
Give a Rack request env object, return a Rack-compatible response.
Constructor Details
#initialize(build_directory:) ⇒ void
Builds an instance of the router. In development mode, we’d expect only one router to be initialized, but in test mode, there’d be a new one for each test.
18 19 20 |
# File 'lib/lifer/dev/router.rb', line 18 def initialize(build_directory:) @build_directory = build_directory end |
Instance Attribute Details
#build_directory ⇒ Object
Returns the value of attribute build_directory.
9 10 11 |
# File 'lib/lifer/dev/router.rb', line 9 def build_directory @build_directory end |
Instance Method Details
#response_for(request_env) ⇒ Lifer::Dev::Response
Give a Rack request env object, return a Rack-compatible response.
26 27 28 29 30 |
# File 'lib/lifer/dev/router.rb', line 26 def response_for(request_env) local_path = local_path_to request_env["PATH_INFO"] Lifer::Dev::Response.new(local_path).build end |