Class: MailToHipChat::RackApp
- Inherits:
-
Object
- Object
- MailToHipChat::RackApp
- Defined in:
- lib/mail_to_hip_chat/rack_app.rb,
lib/mail_to_hip_chat/rack_app/builder.rb
Defined Under Namespace
Classes: Builder
Constant Summary collapse
- SIGNATURE_PARAM_NAME =
"signature"
Instance Method Summary collapse
- #call(rack_env) ⇒ Object
-
#initialize(opts = {}) {|_self| ... } ⇒ RackApp
constructor
A new instance of RackApp.
- #use_chute(chute) ⇒ Object
Constructor Details
#initialize(opts = {}) {|_self| ... } ⇒ RackApp
Returns a new instance of RackApp.
11 12 13 14 15 16 |
# File 'lib/mail_to_hip_chat/rack_app.rb', line 11 def initialize(opts = {}) @secret = opts[:secret] @chute_chain = opts[:chute_chain] || ChuteChain.new yield(self) if block_given? end |
Instance Method Details
#call(rack_env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mail_to_hip_chat/rack_app.rb', line 18 def call(rack_env) request = Rack::Request.new(rack_env) return [400, {}, ['Bad Request.']] unless valid_request?(request) if @chute_chain.accept(request.params) [200, {}, ['OK']] else [404, {}, ['Not Found.']] end rescue Exception => error error.extend(InternalError) raise error end |
#use_chute(chute) ⇒ Object
33 34 35 |
# File 'lib/mail_to_hip_chat/rack_app.rb', line 33 def use_chute(chute) @chute_chain.push(chute) end |