Class: Hyperion::Kim::Handler
- Inherits:
-
Struct
- Object
- Struct
- Hyperion::Kim::Handler
- Defined in:
- lib/hyperion_test/kim.rb
Overview
A dumb fake web server. This is minimal object wrapper around Rack/WEBrick. WEBrick was chosen because it comes with ruby and we’re not doing rocket science here. Kim runs Rack/WEBrick in a separate thread and keeps an array of handlers. A handler is simply a predicate on a request object and a function to handle the request should the predicate return truthy. When rack notifies us of a request, we dispatch it to the first handler with a truthy predicate.
Again, what we’re trying to do is very simple. Most of the existing complexity is due to
-
thread synchronization
-
unmangling WEBrick’s header renaming
-
loosening the requirements on what a handler function must return
To support path parameters (e.g., /people/:name), a predicate may return a Request object as a truthy value, augmented with additional params. When the predicate returns a Request, the augmented request object is passed to the handler function in place of the original request.
Instance Attribute Summary collapse
-
#func ⇒ Object
Returns the value of attribute func.
-
#pred ⇒ Object
Returns the value of attribute pred.
Instance Attribute Details
#func ⇒ Object
Returns the value of attribute func
30 31 32 |
# File 'lib/hyperion_test/kim.rb', line 30 def func @func end |
#pred ⇒ Object
Returns the value of attribute pred
30 31 32 |
# File 'lib/hyperion_test/kim.rb', line 30 def pred @pred end |