Class: ExtDirect::Router
- Inherits:
-
Object
- Object
- ExtDirect::Router
- Defined in:
- lib/ext_direct/router.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, route_path = "/direct") ⇒ Router
constructor
A new instance of Router.
Constructor Details
#initialize(app, route_path = "/direct") ⇒ Router
Returns a new instance of Router.
5 6 7 |
# File 'lib/ext_direct/router.rb', line 5 def initialize(app, route_path = "/direct") @app, @route_path = app, route_path end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ext_direct/router.rb', line 9 def call(env) if env["PATH_INFO"].match("^#{@route_path}") request = ExtDirect::Request.new(env) response = ExtDirect::Response.new("", 200, {"Content-Type" => "application/json"}) # direct requests from the client ExtDirect::Dispatcher.dispatch(request, response) response.finish else @app.call(env) end end |