Class: Lita::HTTPCallback Private
- Inherits:
-
Object
- Object
- Lita::HTTPCallback
- Defined in:
- lib/lita/http_callback.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A wrapper around a handler’s HTTP route callbacks that sets up the request and response.
Instance Method Summary collapse
-
#call(env) ⇒ Object
private
Call the Rack endpoint with a standard environment hash.
-
#initialize(handler_class, callback) ⇒ HTTPCallback
constructor
private
A new instance of HTTPCallback.
Constructor Details
#initialize(handler_class, callback) ⇒ HTTPCallback
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of HTTPCallback.
8 9 10 11 |
# File 'lib/lita/http_callback.rb', line 8 def initialize(handler_class, callback) @handler_class = handler_class @callback = callback end |
Instance Method Details
#call(env) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Call the Rack endpoint with a standard environment hash.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lita/http_callback.rb', line 14 def call(env) request = Rack::Request.new(env) response = Rack::Response.new if request.head? response.status = 204 else begin handler = @handler_class.new(env["lita.robot"]) @callback.call(handler, request, response) rescue Exception => e env["lita.robot"].config.robot.error_handler.call(e) raise end end response.finish end |