Class: NuHttp::App
- Inherits:
-
Object
- Object
- NuHttp::App
- Defined in:
- lib/nuhttp/app.rb
Instance Method Summary collapse
-
#dispatch(req) ⇒ Object
The entrypoint of the request.
-
#initialize(router) ⇒ App
constructor
A new instance of App.
- #routes ⇒ Object
Constructor Details
#initialize(router) ⇒ App
Returns a new instance of App.
6 7 8 |
# File 'lib/nuhttp/app.rb', line 6 def initialize(router) @router = router end |
Instance Method Details
#dispatch(req) ⇒ Object
The entrypoint of the request.
12 13 14 15 16 17 18 19 20 |
# File 'lib/nuhttp/app.rb', line 12 def dispatch(req) route, params = @router.resolve(req) # Create a new Context ctx = Context.new(req:, route:) # Populate req.params req.params = params route.handler.call(ctx) ctx.res end |
#routes ⇒ Object
22 23 24 |
# File 'lib/nuhttp/app.rb', line 22 def routes @router.routes end |