Class: LogStruct::Integrations::HostAuthorization::ResponseApp

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/log_struct/integrations/host_authorization.rb

Overview

Logs the blocked host, then responds with the app's own response_app if it set one

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_response_app) ⇒ void

Parameters:

  • app_response_app (T.untyped)


61
62
63
# File 'lib/log_struct/integrations/host_authorization.rb', line 61

def initialize(app_response_app)
  @app_response_app = app_response_app
end

Instance Attribute Details

#app_response_app ⇒ T.untyped (readonly)

Returns:

  • (T.untyped)


58
59
60
# File 'lib/log_struct/integrations/host_authorization.rb', line 58

def app_response_app
  @app_response_app
end

Instance Method Details

#call(env) ⇒ T.untyped

Parameters:

  • env (Hash{String => T.untyped})

Returns:

  • (T.untyped)


66
67
68
69
70
71
72
73
74
75
76
# File 'lib/log_struct/integrations/host_authorization.rb', line 66

def call(env)
  begin
    log_blocked_host(env)
  rescue => e
    LogStruct.handle_exception(e, source: LogStruct::Source::Internal, context: {integration: :host_authorization})
  end
  return @app_response_app.call(env) if @app_response_app

  # Dup the headers so they can be modified by downstream middleware
  [FORBIDDEN_STATUS, RESPONSE_HEADERS.dup, [RESPONSE_HTML]]
end