Class: Rx::Util::HealthCheckAuthorization

Inherits:
Object
  • Object
show all
Defined in:
lib/rx/util/health_check_authorization.rb

Constant Summary collapse

HTTP_HEADER =
"HTTP_AUTHORIZATION"

Instance Method Summary collapse

Constructor Details

#initialize(env, authorization) ⇒ HealthCheckAuthorization

Returns a new instance of HealthCheckAuthorization.



6
7
8
9
# File 'lib/rx/util/health_check_authorization.rb', line 6

def initialize(env, authorization)
  @authorization = authorization
  @env = env
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rx/util/health_check_authorization.rb', line 11

def ok?
  case @authorization
    when NilClass
      true
    when Proc
      @authorization.call(@env)
    when String
      @authorization == @env[HTTP_HEADER]
    else
      raise StandardError.new("Authorization is not configured properly")
  end
end