Sha256: 674a195fe8b212a22d64ce3997278fe56234c4cff15486305e4b3525f7cd8c68

Contents?: true

Size: 563 Bytes

Versions: 2

Compression:

Stored size: 563 Bytes

Contents

require 'json'

module ExtDirect
  class Router
    def initialize(app, route_path = "/direct")
      @app, @route_path = app, route_path
    end
    
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ext_direct-0.3.0 lib/ext_direct/router.rb
ext_direct-0.2.0 lib/ext_direct/router.rb