Sha256: 07ff90def6269d9e6f3d20649eb3a8667cb6fa284f4cf2b8a9878f96a56cab26

Contents?: true

Size: 551 Bytes

Versions: 1

Compression:

Stored size: 551 Bytes

Contents

require 'json'

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

1 entries across 1 versions & 1 rubygems

Version Path
ext_direct-0.1.1 lib/ext_direct/router.rb