Class: Banacle::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/banacle/handler.rb

Defined Under Namespace

Classes: InvalidAuthenticatorError

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



8
9
10
# File 'lib/banacle/handler.rb', line 8

def auth
  @auth
end

#requestObject (readonly)

Returns the value of attribute request.



8
9
10
# File 'lib/banacle/handler.rb', line 8

def request
  @request
end

Instance Method Details

#handle(request) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/banacle/handler.rb', line 10

def handle(request)
  @request = request

  unless skip_validation? || SlackValidator.valid_signature?(request)
    return [401, {}, "invalid request"]
  end

  handle_request
end

#handle_requestObject

override



21
22
# File 'lib/banacle/handler.rb', line 21

def handle_request
end

#set_authenticator!(auth) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/banacle/handler.rb', line 24

def set_authenticator!(auth)
  unless auth.is_a?(Banacle::Authenticator)
    raise InvalidAuthenticatorError.new(auth.inspect)
  end

  @auth = auth
end