Class: ExtDirect::API
- Inherits:
-
Object
- Object
- ExtDirect::API
- Defined in:
- lib/ext_direct/api.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, api_path = "/api", route_path = "/direct", constant_name = "Ext.app.REMOTING_API") ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(app, api_path = "/api", route_path = "/direct", constant_name = "Ext.app.REMOTING_API") ⇒ API
Returns a new instance of API.
5 6 7 |
# File 'lib/ext_direct/api.rb', line 5 def initialize(app, api_path = "/api", route_path = "/direct", constant_name = "Ext.app.REMOTING_API") @app, @api_path, @route_path, @constant_name = app, api_path, route_path, constant_name end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/ext_direct/api.rb', line 9 def call(env) if env["PATH_INFO"].match("^#{@api_path}$") response = ExtDirect::Response.new("", 200, {"Content-Type" => "text/javascript"}) response.write("#{@constant_name} = #{ExtDirect::Service::Configuration.generate(@route_path).to_json}") response.finish else @app.call(env) end end |